Trait parity_map::ParityMap
source · pub trait ParityMap: Sized {
// Required method
fn parity(&self) -> Parity;
// Provided methods
fn parity_map(
self,
odd: impl FnOnce(Self) -> Self,
even: impl FnOnce(Self) -> Self
) -> Self { ... }
fn parity_map_and_then<F>(
self,
odd: impl FnOnce(Self) -> Self,
even: impl FnOnce(Self) -> Self,
after: impl FnOnce(Self) -> Self
) -> Self { ... }
fn map_even(self, f: impl FnOnce(Self) -> Self) -> Self { ... }
fn map_odd(self, f: impl FnOnce(Self) -> Self) -> Self { ... }
}Expand description
Gives access to methods for mapping based on a number’s parity.
Required Methods§
Provided Methods§
sourcefn parity_map(
self,
odd: impl FnOnce(Self) -> Self,
even: impl FnOnce(Self) -> Self
) -> Self
fn parity_map( self, odd: impl FnOnce(Self) -> Self, even: impl FnOnce(Self) -> Self ) -> Self
Returns odd(self) if self is odd, else even(self).
sourcefn parity_map_and_then<F>(
self,
odd: impl FnOnce(Self) -> Self,
even: impl FnOnce(Self) -> Self,
after: impl FnOnce(Self) -> Self
) -> Self
fn parity_map_and_then<F>( self, odd: impl FnOnce(Self) -> Self, even: impl FnOnce(Self) -> Self, after: impl FnOnce(Self) -> Self ) -> Self
Calls a function on the result of self.parity_map(..), returning the result.
Object Safety§
This trait is not object safe.