Trait DefaultFilterable

Source
pub trait DefaultFilterable {
    type Filtered<'a>
       where Self: 'a;
    type Error: Into<Error>;

    // Required method
    fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>;
}
Expand description

A type (or a reference to it) that can be used in |assigned_or.

The type is either a monad such as Option or Result, or a type that has a well defined, trivial default value, e.g. an empty str or 0 for integer types.

Required Associated Types§

Source

type Filtered<'a> where Self: 'a

The contained value

Source

type Error: Into<Error>

An error that prevented as_filtered() to succeed, e.g. a poisoned state or an unacquirable lock.

Required Methods§

Source

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Return the contained value, if a value was contained, and it’s not the default value.

Returns Ok(None) if the value could not be unwrapped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl DefaultFilterable for bool

A bool has a value if it is true.

Source§

impl DefaultFilterable for f32

An f32 has a value if it is Normal, i.e. it is not zero, not sub-normal, not infinite and not NaN.

Source§

type Filtered<'a> = f32 where Self: 'a

Source§

type Error = Infallible

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl DefaultFilterable for f64

An f64 has a value if it is Normal, i.e. it is not zero, not sub-normal, not infinite and not NaN.

Source§

type Filtered<'a> = f64 where Self: 'a

Source§

type Error = Infallible

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl DefaultFilterable for i8

A i8 has a value if it is not 0.

Source§

impl DefaultFilterable for i16

A i16 has a value if it is not 0.

Source§

impl DefaultFilterable for i32

A i32 has a value if it is not 0.

Source§

impl DefaultFilterable for i64

A i64 has a value if it is not 0.

Source§

impl DefaultFilterable for i128

A i128 has a value if it is not 0.

Source§

impl DefaultFilterable for isize

A isize has a value if it is not 0.

Source§

impl DefaultFilterable for str

A str has a value if it is not empty.

Source§

type Filtered<'a> = &'a str where Self: 'a

Source§

type Error = Infallible

Source§

fn as_filtered(&self) -> Result<Option<&str>, Infallible>

Source§

impl DefaultFilterable for u8

A u8 has a value if it is not 0.

Source§

impl DefaultFilterable for u16

A u16 has a value if it is not 0.

Source§

impl DefaultFilterable for u32

A u32 has a value if it is not 0.

Source§

impl DefaultFilterable for u64

A u64 has a value if it is not 0.

Source§

impl DefaultFilterable for u128

A u128 has a value if it is not 0.

Source§

impl DefaultFilterable for usize

A usize has a value if it is not 0.

Source§

impl DefaultFilterable for String

A String has a value if it is not empty.

Source§

type Filtered<'a> = &'a str where Self: 'a

Source§

type Error = Infallible

Source§

fn as_filtered(&self) -> Result<Option<&str>, Infallible>

Source§

impl DefaultFilterable for NonZeroI8

A NonZeroI8 always has a value.

Source§

impl DefaultFilterable for NonZeroI16

A NonZeroI16 always has a value.

Source§

impl DefaultFilterable for NonZeroI32

A NonZeroI32 always has a value.

Source§

impl DefaultFilterable for NonZeroI64

A NonZeroI64 always has a value.

Source§

impl DefaultFilterable for NonZeroI128

A NonZeroI128 always has a value.

Source§

impl DefaultFilterable for NonZeroIsize

A NonZeroIsize always has a value.

Source§

impl DefaultFilterable for NonZeroU8

A NonZeroU8 always has a value.

Source§

impl DefaultFilterable for NonZeroU16

A NonZeroU16 always has a value.

Source§

impl DefaultFilterable for NonZeroU32

A NonZeroU32 always has a value.

Source§

impl DefaultFilterable for NonZeroU64

A NonZeroU64 always has a value.

Source§

impl DefaultFilterable for NonZeroU128

A NonZeroU128 always has a value.

Source§

impl DefaultFilterable for NonZeroUsize

A NonZeroUsize always has a value.

Source§

impl<T> DefaultFilterable for Option<T>

An Option has a value if it is Some.

Source§

impl<T> DefaultFilterable for Pin<T>
where T: Deref, <T as Deref>::Target: DefaultFilterable,

A pinned reference has a value if the referenced data has a value.

Source§

type Filtered<'a> = <<T as Deref>::Target as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <<T as Deref>::Target as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ToOwned + ?Sized> DefaultFilterable for Cow<'_, T>

A Cow has a value if it’s borrowed data has a value.

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for &T

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for &mut T

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for Box<T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for Rc<T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for Arc<T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for Ref<'_, T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for RefMut<'_, T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for MutexGuard<'_, T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for RwLockReadGuard<'_, T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable + ?Sized> DefaultFilterable for RwLockWriteGuard<'_, T>

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable> DefaultFilterable for Saturating<T>

A Saturating integer has a value if it is not 0.

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Source§

impl<T: DefaultFilterable> DefaultFilterable for Wrapping<T>

A Wrapping integer has a value if it is not 0.

Source§

type Filtered<'a> = <T as DefaultFilterable>::Filtered<'a> where Self: 'a

Source§

type Error = <T as DefaultFilterable>::Error

Source§

fn as_filtered(&self) -> Result<Option<Self::Filtered<'_>>, Self::Error>

Implementors§

Source§

impl<T, E> DefaultFilterable for Result<T, E>

A Result has a value if it is Ok.

Source§

type Filtered<'a> = &'a T where Self: 'a

Source§

type Error = Infallible