shallow

Crates.ioshallow
lib.rsshallow
version0.2.0
sourcesrc
created_at2023-05-11 10:03:06.422398
updated_at2023-05-12 12:44:59.916636
descriptionshallow long text
homepage
repositoryhttps://github.com/oovm/pex
max_upload_size
id861945
size8,278
SasakiSaki (oovm)

documentation

https://docs.rs/shallow

README

Text Shallow

  • character by character, place-holder mode
# use shallow::CharacterShallow;

#[test]
fn fill_placeholder() {
    const TEXT10: &str = "1234567890";
    const TEXT21: &str = "1234567890_1234567890";
    const TEXT27: &str = "1234567890_1234567890_12345";
    let sb = CharacterShallow::new(21, 5);
    assert_eq!(sb.build_cow(TEXT10), TEXT10);
    assert_eq!(sb.build_cow(TEXT21), "1234567890_1234567890"); // nothing changed
    assert_eq!(sb.build_cow(TEXT27), "123456789 <...> 12345");
    let sb = sb.with_shallow_text("..."); // replace shallow text
    assert_eq!(sb.build_cow(TEXT27), "1234567890_12...12345");
    let sb = sb.with_end_reserved(0); // cancel end reserved
    assert_eq!(sb.build_cow(TEXT27), "1234567890_1234567...");
}
Commit count: 0

cargo fmt