string_patterns/enums.rs
1
2/// Defines the start, end and both bounds of a word
3pub enum WordBounds {
4 None,
5 Start,
6 End,
7 Both,
8}
9
10impl WordBounds {
11 /// Convert word bounds
12 pub fn to_pattern(&self, word: &str) -> String {
13 match self {
14 WordBounds::Start => [r#"\b"#, word].concat(),
15 WordBounds::End => [word, r#"\b"#].concat(),
16 WordBounds::Both => [r#"\b"#, word, r#"\b"#].concat(),
17 _ => word.to_owned(),
18 }
19 }
20}