Skip to main content

Extracted

Enum Extracted 

Source
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>

Source

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}
Source

pub fn is_not_found(&self) -> bool

Returns true if no value was found and no default applied.

Source

pub fn is_defaulted(&self) -> bool

Returns true if the value was defaulted.

Source

pub fn value(&self) -> Option<&T>

Returns the inner value regardless of whether it was found or defaulted. Returns None if NotFound.

Trait Implementations§

Source§

impl<T: Clone> Clone for Extracted<T>

Source§

fn clone(&self) -> Extracted<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Extracted<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq> PartialEq for Extracted<T>

Source§

fn eq(&self, other: &Extracted<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for Extracted<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.