pub enum Extracted<T> {
Found(T),
NotFound,
Defaulted(T),
}Expand description
The outcome of attempting to extract a single date component (day, month, or year).
Variants§
Found(T)
The value was found directly in the input.
NotFound
No value could be found and no default was configured.
Defaulted(T)
The value was not found in the input but a default was applied.
Implementations§
Source§impl<T> Extracted<T>
impl<T> Extracted<T>
Sourcepub fn is_found(&self) -> bool
pub fn is_found(&self) -> bool
Returns true if the value was found in the input.
Examples found in repository?
examples/all_examples.rs (line 586)
566fn example_21_fuzzy_month_name() {
567 println!("2️⃣1️⃣ FUZZY MONTH MATCHING: Misspellings");
568 println!(" Testing Levenshtein distance fuzzy matching\n");
569
570 let cases = vec![
571 ("25 Januray 2024", "Januray (transposition)"),
572 ("15 Decmber 2024", "Decmber (missing letter)"),
573 ("31 Ocotber 2024", "Ocotber (swap)"),
574 ];
575
576 for (input_str, description) in cases {
577 let input = Input {
578 utterance: input_str.to_string(),
579 config: None,
580 };
581 let result = extract(input);
582 println!(
583 " {} → {:?} {}",
584 description,
585 result.month.name,
586 if result.month.number.is_found() {
587 "✓"
588 } else {
589 "✗"
590 }
591 );
592 }
593 println!();
594}Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true if no value was found and no default applied.
Sourcepub fn is_defaulted(&self) -> bool
pub fn is_defaulted(&self) -> bool
Returns true if the value was defaulted.
Trait Implementations§
impl<T: Eq> Eq for Extracted<T>
impl<T> StructuralPartialEq for Extracted<T>
Auto Trait Implementations§
impl<T> Freeze for Extracted<T>where
T: Freeze,
impl<T> RefUnwindSafe for Extracted<T>where
T: RefUnwindSafe,
impl<T> Send for Extracted<T>where
T: Send,
impl<T> Sync for Extracted<T>where
T: Sync,
impl<T> Unpin for Extracted<T>where
T: Unpin,
impl<T> UnsafeUnpin for Extracted<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Extracted<T>where
T: UnwindSafe,
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