Generate strings that can sort between two other strings.
between is a Rust port of the between2 npm package.
https://crates.io/crates/between
cargo add betweenInitializes Between with a custom set of characters.
use between::Between;
let between = Between::new(vec!['a', 'b', 'c', 'd', 'e']);By default, Between uses the following characters to generate strings:
!0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
Generates a string that lexicographically sorts between a and b.
amust be lexicographically less thanb. In other words,a < b.aandbcan be any string that does not end in the lowest character. this is like how there is only one number between 0 and 1 that ends in a "0".
let tween = between.between(String::from("a"), String::from("b"));tween is an Option<String> that, if Some, contains a string that will sort between 'a' and 'b'.
Generate a string that sorts between a and the highest character (between.high()).
The string a cannot begin with the highest character.
Generate a string that sorts between the lowest character (between.low()) and a.
All credit to @dominictarr for creating the original between module, which inspired this Rust port.
MIT.