trim_matches_exactly

Crates.iotrim_matches_exactly
lib.rstrim_matches_exactly
version0.1.0
sourcesrc
created_at2018-07-22 15:22:01.207442
updated_at2018-07-22 15:22:01.207442
descriptionExtension trait for controlled trimming of prefixes and suffixes of &str and String
homepage
repositoryhttps://github.com/CodeSandwich/trim_matches_exactly
max_upload_size
id75512
size10,332
(CodeSandwich)

documentation

README

Extension trait for controlled trimming of prefixes and suffixes of &str and String.

Provided methods trim only if the given pattern matches exact number of times, otherwise they return the unmodified &str. This can be used for primitive parsing and text analysis.

assert_eq!(Ok("trimmed"), "not trimmed".trim_left_matches_exactly("not ", 1));
assert_eq!(Err("not trimmed"), "not trimmed".trim_left_matches_exactly("very ", 1));
assert_eq!(Ok("trimmed"), "tttrimmed".trim_left_matches_exactly('t', 2));
Commit count: 4

cargo fmt