Generate lexicographically-evenly-spaced strings between two strings from pre-defined alphabets.
This is a rewrite of mudderjs; thanks for the original work of the author and their contributors!
Add a dependency in your Cargo.toml:
toml
mudders = "0.0.1"
Now you can generate lexicographically-spaced strings in a few different ways:
``rust
use mudders::SymbolTable;
// You can use the included alphabet table
let table = SymbolTable::alphabet();
// SymbolTable::mudder() returns a Vec containing
amountStrings.
let result = table.mudder("a", "z", 1);
// These strings are always lexicographically placed between
startand
end`.
let onestring = result[0].asstr();
assert!(onestring > "a");
assert!(onestring < "z");
// You can also define your own symbol tables let table = SymbolTable::fromchars(&['a', 'b']).unwrap(); let result = table.mudder("a", "b", 2); asserteq!(result.len(), 2); assert!(result[0].asstr() > "a", result[1].asstr() > "a"); assert!(result[0].asstr() < "b", result[1].asstr() < "b");
// The strings should be evenly-spaced and as short as they can be. let table = SymbolTable::alphabet(); let result = table.mudder("anhui", "azazel", 3); asserteq!(result.len(), 3); asserteq!(vec!["aq", "at", "aw"], result); ```
The most notable difference to Mudder.js is that currently, mudders only
supports ASCII characters (because 127 characters ought to be enough for
everyone™). Our default ::alphabet()
also only has lowercase letters.