password-rules-parser icon indicating copy to clipboard operation
password-rules-parser copied to clipboard

Provide a `Display` implementation for `CharacterClass`

Open Cldfire opened this issue 5 years ago • 0 comments

While writing https://github.com/Cldfire/password-rules-checker I came across a place where it would be nice to have a way to pretty-print a CharacterClass:

let possibly_shortened_allows = remove_unecessary_allows(&quirk_parsed);

if quirk_parsed.allowed != possibly_shortened_allows {
    // TODO: pretty print the suggestion
    println!(
        "{}: the `allowed` property for this rule can be shortened to: {:?}",
        site, possibly_shortened_allows
    );
}

I'd like to print allowed: upper, [%^*]; instead of [Upper, Custom(['%', '^', '*'])]. A Display impl for CharacterClass would make that simple.

Cldfire avatar Dec 24 '20 00:12 Cldfire