Trait TakeIf

Source
pub trait TakeIf {
    type Inner;

    // Required method
    fn take_if<F: FnOnce(&Self::Inner) -> bool>(
        &mut self,
        predicate: F,
    ) -> Option<Self::Inner>;
}
Expand description

Extension trait for Option<T> that adds the take_if method.

See the crate-level documentation for more information.

Required Associated Types§

Source

type Inner

The type contained in the Option.

Required Methods§

Source

fn take_if<F: FnOnce(&Self::Inner) -> bool>( &mut self, predicate: F, ) -> Option<Self::Inner>

Takes value out of the Option if predicate returns true.

See the crate-level documentation for more information.

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<T> TakeIf for Option<T>

Source§

type Inner = T

Source§

fn take_if<F: FnOnce(&Self::Inner) -> bool>( &mut self, predicate: F, ) -> Option<Self::Inner>

Implementors§