Struct synthez::Required

source ·
pub struct Required<T>(_);
Expand description

Container requiring a field to have a value mandatory.

It’s similar to an Option, but panics on accessing to an absent underlying value. So, is not intended to be created directly in user code, but rather only used for marking types in struct fields, so this library machinery may kick in and take care of correct values creation without introducing any panics.

Accessing the underlying value, stored in this wrapper, is intended to be done via Deref and DerefMut in user code.

Implementations§

source§

impl<T> Required<T>

source

pub fn into_inner(self) -> T

Unwraps this Required Container returning the underlying value.

Panics

If this Container hasn’t been initialized properly, so contains no value.

Trait Implementations§

source§

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

source§

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

Returns a copy 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<V> Container<V> for Required<V>

§

type Value = V

Type of values contained in this Container.
source§

fn is_empty(&self) -> bool

Indicates whether this Container is empty (contains no values).
source§

fn has(&self, _: &V) -> bool

Indicates whether the provided value is present in this Container.
source§

fn replace(&mut self, val: V) -> Option<V>

Replaces the value contained in this Container with the provided one, and returns the replaced one, if any.
source§

fn set(&mut self, value: V)

Sets the provided value into this Container, dropping the previous one, if any.
source§

impl<T> Debug for Required<T>where T: Debug,

source§

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

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

impl<T> Deref for Required<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Required<T> as Deref>::Target

Dereferences the value.
source§

impl<T> DerefMut for Required<T>

source§

fn deref_mut(&mut self) -> &mut <Required<T> as Deref>::Target

Mutably dereferences the value.
source§

impl<'a, T> IntoIterator for &'a Required<T>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Once<&'a T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a Required<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoIterator for &'a mut Required<T>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = Once<&'a mut T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a mut Required<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for Required<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = Once<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <Required<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<V, K> TryApply<V, K, First> for Required<V>where K: Kind + Single + ?Sized,

source§

fn try_apply(&mut self, val: V) -> Result<(), Error>

Applies the provided value to this field::Container. Read more
source§

impl<V, K> TryApply<V, K, Last> for Required<V>where K: Kind + Single + ?Sized,

source§

fn try_apply(&mut self, val: V) -> Result<(), Error>

Applies the provided value to this field::Container. Read more
source§

impl<V, K> TryApply<V, K, Unique> for Required<V>where &'a V: for<'a> IntoSpan, K: Kind + Single + ?Sized,

source§

fn try_apply(&mut self, val: V) -> Result<(), Error>

Applies the provided value to this field::Container. Read more
source§

impl<V, K, D> TryApplySelf<V, K, D> for Required<V>where K: Kind + Single + ?Sized, D: Dedup + ?Sized, Required<V>: TryApply<V, K, D>,

source§

fn try_apply_self(&mut self, another: Required<V>) -> Result<(), Error>

Applies the value extracted from another field::Container to this field::Container. Read more
source§

impl<V> Validation<Provided> for Required<V>

source§

fn validation(&self) -> Result<(), Error>

Checks whether the validation Rule is satisfied. Read more
source§

impl<T> Copy for Required<T>where T: Copy,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Required<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T, V> TryMerge<V> for Twhere T: ?Sized,

source§

fn try_merge<K, D>(&mut self, val: V) -> Result<(), Error>where T: TryApply<V, K, D>, K: Kind + ?Sized, D: Dedup + ?Sized,

Merges the provided value to this field::Container with the specified parsing Kind and Deduplication strategy. Read more
source§

fn try_merge_self<K, D>(&mut self, another: T) -> Result<(), Error>where T: TryApplySelf<V, K, D>, K: Kind + ?Sized, D: Dedup + ?Sized,

Merges the value extracted from another field::Container to this field::Container with the specified parsing Kind and Deduplication strategy. Read more
source§

impl<T> Validate for Twhere T: ?Sized,

source§

fn validate<R>(&self) -> Result<(), Error>where R: Rule + ?Sized, T: Validation<R>,

Checks whether the specified validation Rule is satisfied. Read more