Skip to main content

Resolved

Enum Resolved 

Source
pub enum Resolved<T> {
    Fact(T),
    Predict(T),
}
Expand description

Результат запроса к календарю: факт или прогноз.

§Семантика

  • Fact(T) — данные присутствуют в официальной таблице производственного календаря.
  • Predict(T) — официальной таблицы нет, результат получен алгоритмическим прогнозом.

§Примеры

use holidays_ru::Resolved;

let r: Resolved<i32> = Resolved::Fact(42);
assert!(r.is_fact());
assert_eq!(r.value(), 42);

let mapped = r.map(|v| v * 2);
assert_eq!(mapped, Resolved::Fact(84));

Variants§

§

Fact(T)

Результат основан на официальных данных производственного календаря.

§

Predict(T)

Результат получен алгоритмическим прогнозом.

Implementations§

Source§

impl<T> Resolved<T>

Source

pub fn value(self) -> T

Извлекает значение, отбрасывая информацию о происхождении.

use holidays_ru::Resolved;

assert_eq!(Resolved::Fact(10).value(), 10);
assert_eq!(Resolved::Predict(20).value(), 20);
Source

pub const fn is_fact(&self) -> bool

Возвращает true, если результат основан на официальных данных.

Source

pub const fn is_predict(&self) -> bool

Возвращает true, если результат получен прогнозом.

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Resolved<U>

Применяет функцию к внутреннему значению, сохраняя обёртку Fact/Predict.

Source

pub const fn as_ref(&self) -> Resolved<&T>

Возвращает внутреннее значение как ссылку.

Trait Implementations§

Source§

impl<T: Clone> Clone for Resolved<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for Resolved<T>

Source§

impl<T: Debug> Debug for Resolved<T>

Source§

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

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

impl<T: Eq> Eq for Resolved<T>

Source§

impl<T: Hash> Hash for Resolved<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Resolved<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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> StructuralPartialEq for Resolved<T>

Auto Trait Implementations§

§

impl<T> Freeze for Resolved<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Resolved<T>
where T: RefUnwindSafe,

§

impl<T> Send for Resolved<T>
where T: Send,

§

impl<T> Sync for Resolved<T>
where T: Sync,

§

impl<T> Unpin for Resolved<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Resolved<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Resolved<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.