Struct FilterMap

Source
pub struct FilterMap<A, F, G> { /* private fields */ }
Expand description

An Adapter that passes each item through an optional function and passes the Some values on.

Trait Implementations§

Source§

impl<F, G, A, B> Adapter for FilterMap<A, F, G>
where F: Fn(A) -> Option<B> + Send, B: Send + 'static, G: Adapter<Item = B> + Send, A: Send,

Source§

type Item = A

Source§

async fn notify(&mut self, a: Self::Item)
where Self::Item: 'static,

Forward the given item to an asynchronous consumer, possibly converting the type or possibly dropping the item if it cannot be converted.
Source§

fn clone_notify(&mut self, a: &Self::Item) -> impl Future<Output = ()> + Send
where Self::Item: Clone + 'static,

Clone the referenced item and then forward it to an asynchonous consumer. The clone operation can is avoid in the Placeholder implementation.
Source§

fn merge<T>(self, other: T) -> impl Adapter<Item = Self::Item>
where T: Adapter<Item = Self::Item>, Self: Sized + Send, Self::Item: Send + Clone,

Combine this with another adapter. The notify call is delegated to both adapters.
Source§

fn with_filter_map<A>( self, func: impl Fn(A) -> Option<Self::Item> + Send, ) -> impl Adapter<Item = A>
where Self: Sized + Send, Self::Item: Send + 'static, A: Send,

Create an adapter that maps items with an optional function. Some values are passed on, analogous to Iterator::filter_map.
Source§

fn with_map<A>( self, func: impl Fn(A) -> Self::Item + Send, ) -> impl Adapter<Item = A>
where Self: Sized + Send, Self::Item: Send + 'static, A: Send,

Create an adapter that maps each item with a function.
Source§

fn adapt<A>(self) -> impl Adapter<Item = A>
where Self: Sized + Send, Self::Item: Send + 'static, A: Into<Self::Item> + Send,

Create an adapter that converts each item from another type. This relies on an Into implementation for the conversion.
Source§

fn adapt_fallible<A>(self) -> impl Adapter<Item = A>
where Self: Sized + Send, Self::Item: Send + 'static, A: TryInto<Self::Item> + Send,

Create an adapter that fallibly converts each item from another type. This relies on an TryInto implementation for the conversion.
Source§

impl<A: Debug, F: Debug, G: Debug> Debug for FilterMap<A, F, G>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, F, G> Freeze for FilterMap<A, F, G>
where F: Freeze, G: Freeze,

§

impl<A, F, G> RefUnwindSafe for FilterMap<A, F, G>

§

impl<A, F, G> Send for FilterMap<A, F, G>
where F: Send, G: Send, A: Send,

§

impl<A, F, G> Sync for FilterMap<A, F, G>
where F: Sync, G: Sync, A: Sync,

§

impl<A, F, G> Unpin for FilterMap<A, F, G>
where F: Unpin, G: Unpin, A: Unpin,

§

impl<A, F, G> UnwindSafe for FilterMap<A, F, G>
where F: UnwindSafe, G: UnwindSafe, A: 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> 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, 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.