pub struct IncludeSet(/* private fields */);Expand description
Regex patterns used to include only matching words.
§Examples
use word_tally::IncludeSet;
// Create a pattern to include only words containing vowels.
let patterns = IncludeSet::new(vec![r"[aeiou]".to_string()]).unwrap();
// Test matching
assert!(patterns.matches("test")); // Contains 'e'
assert!(!patterns.matches("rhythm")); // No vowelsImplementations§
Source§impl IncludeSet
impl IncludeSet
Sourcepub fn new(input_patterns: PatternList) -> Result<Self, WordTallyError>
pub fn new(input_patterns: PatternList) -> Result<Self, WordTallyError>
Creates patterns from owned pattern strings.
§Examples
use word_tally::IncludeSet;
// Create patterns for including words with specific prefixes.
let patterns = IncludeSet::new(vec![r"^pre".to_string(), r"^un".to_string()]).unwrap();
assert_eq!(patterns.len(), 2);
assert!(patterns.matches("prevent"));
assert!(patterns.matches("unlike"));
assert!(!patterns.matches("likely"));§Errors
Returns an error if any pattern cannot be compiled into a valid regular expression.
Sourcepub fn as_patterns(&self) -> &[String]
pub fn as_patterns(&self) -> &[String]
Returns a slice of the original pattern strings.
Trait Implementations§
Source§impl AsRef<[String]> for IncludeSet
impl AsRef<[String]> for IncludeSet
Source§impl Clone for IncludeSet
impl Clone for IncludeSet
Source§fn clone(&self) -> IncludeSet
fn clone(&self) -> IncludeSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IncludeSet
impl Debug for IncludeSet
Source§impl Default for IncludeSet
impl Default for IncludeSet
Source§fn default() -> IncludeSet
fn default() -> IncludeSet
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for IncludeSet
impl<'de> Deserialize<'de> for IncludeSet
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for IncludeSet
impl Display for IncludeSet
Source§impl Hash for IncludeSet
impl Hash for IncludeSet
Source§impl Ord for IncludeSet
impl Ord for IncludeSet
Source§impl PartialEq for IncludeSet
impl PartialEq for IncludeSet
Source§impl PartialOrd for IncludeSet
impl PartialOrd for IncludeSet
Source§impl Serialize for IncludeSet
impl Serialize for IncludeSet
Source§impl<'a> TryFrom<&'a [String]> for IncludeSet
impl<'a> TryFrom<&'a [String]> for IncludeSet
impl Eq for IncludeSet
Auto Trait Implementations§
impl Freeze for IncludeSet
impl RefUnwindSafe for IncludeSet
impl Send for IncludeSet
impl Sync for IncludeSet
impl Unpin for IncludeSet
impl UnwindSafe for IncludeSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more