Skip to main content

SendThunkBrand

Struct SendThunkBrand 

Source
pub struct SendThunkBrand;
Expand description

Brand for SendThunk.

Thread-safe counterpart of ThunkBrand. The inner closure is Send, enabling deferred computation across thread boundaries.

§HKT limitations

SendThunkBrand does not implement Functor, Monad, or any other HKT type-class traits. Those traits accept closure parameters as impl Fn/impl FnOnce without a Send bound, so there is no way to guarantee that the closures passed to map, bind, etc. are safe to store inside a Send thunk. Use ThunkBrand when HKT polymorphism is needed, or work with SendThunk directly through its inherent methods.

Trait Implementations§

Source§

impl Clone for SendThunkBrand

Source§

fn clone(&self) -> SendThunkBrand

Returns a duplicate 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 Debug for SendThunkBrand

Source§

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

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

impl Default for SendThunkBrand

Source§

fn default() -> SendThunkBrand

Returns the “default value” for a type. Read more
Source§

impl Foldable for SendThunkBrand

Source§

fn fold_right<'a, FnBrand, A: 'a + Clone, B: 'a>( func: impl Fn(A, B) -> B + 'a, initial: B, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
where FnBrand: CloneFn + 'a,

Folds the SendThunk from the right.

§Type Signature

forall A B. CloneFn FnBrand => ((A, B) -> B, B, SendThunk A) -> B

§Type Parameters
  • 'a: The lifetime of the computation.
  • FnBrand: The brand of the cloneable function to use.
  • A: The type of the elements in the structure.
  • B: The type of the accumulator.
§Parameters
  • func: The function to apply to each element and the accumulator.
  • initial: The initial value of the accumulator.
  • fa: The SendThunk to fold.
§Returns

The final accumulator value.

§Examples
use fp_library::{
	brands::*,
	functions::*,
	types::*,
};

let thunk = SendThunk::pure(10);
let result =
	explicit::fold_right::<RcFnBrand, SendThunkBrand, _, _, _, _>(|a, b| a + b, 5, thunk);
assert_eq!(result, 15);
Source§

fn fold_left<'a, FnBrand, A: 'a + Clone, B: 'a>( func: impl Fn(B, A) -> B + 'a, initial: B, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
where FnBrand: CloneFn + 'a,

Folds the SendThunk from the left.

§Type Signature

forall A B. CloneFn FnBrand => ((B, A) -> B, B, SendThunk A) -> B

§Type Parameters
  • 'a: The lifetime of the computation.
  • FnBrand: The brand of the cloneable function to use.
  • A: The type of the elements in the structure.
  • B: The type of the accumulator.
§Parameters
  • func: The function to apply to the accumulator and each element.
  • initial: The initial value of the accumulator.
  • fa: The SendThunk to fold.
§Returns

The final accumulator value.

§Examples
use fp_library::{
	brands::*,
	functions::*,
	types::*,
};

let thunk = SendThunk::pure(10);
let result =
	explicit::fold_left::<RcFnBrand, SendThunkBrand, _, _, _, _>(|b, a| b + a, 5, thunk);
assert_eq!(result, 15);
Source§

fn fold_map<'a, FnBrand, A: 'a + Clone, M>( func: impl Fn(A) -> M + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> M
where M: Monoid + 'a, FnBrand: CloneFn + 'a,

Maps the value to a monoid and returns it.

§Type Signature

forall A M. (Monoid M, CloneFn FnBrand) => (A -> M, SendThunk A) -> M

§Type Parameters
  • 'a: The lifetime of the computation.
  • FnBrand: The brand of the cloneable function to use.
  • A: The type of the elements in the structure.
  • M: The type of the monoid.
§Parameters
  • func: The mapping function.
  • fa: The SendThunk to fold.
§Returns

The monoid value.

§Examples
use fp_library::{
	brands::*,
	functions::*,
	types::*,
};

let thunk = SendThunk::pure(10);
let result =
	explicit::fold_map::<RcFnBrand, SendThunkBrand, _, _, _, _>(|a: i32| a.to_string(), thunk);
assert_eq!(result, "10");
Source§

impl FoldableWithIndex for SendThunkBrand

Source§

fn fold_map_with_index<'a, FnBrand, A: 'a + Clone, R: Monoid>( f: impl Fn((), A) -> R + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> R
where FnBrand: LiftFn + 'a,

Folds the send thunk using a monoid, providing the index ().

§Type Signature

forall A R. Monoid R => (((), A) -> R, SendThunk A) -> R

§Type Parameters
  • 'a: The lifetime of the computation.
  • FnBrand: The brand of the cloneable function to use.
  • A: The type of the value inside the send thunk.
  • R: The monoid type.
§Parameters
  • f: The function to apply to the value and its index.
  • fa: The send thunk to fold.
§Returns

The monoid value.

§Examples
use fp_library::{
	brands::*,
	classes::foldable_with_index::FoldableWithIndex,
	types::*,
};

let thunk = SendThunk::pure(5);
let result = <SendThunkBrand as FoldableWithIndex>::fold_map_with_index::<RcFnBrand, _, _>(
	|_, x: i32| x.to_string(),
	thunk,
);
assert_eq!(result, "5");
Source§

fn fold_right_with_index<'a, FnBrand, A: 'a + Clone, B: 'a>( func: impl Fn(Self::Index, A, B) -> B + 'a, initial: B, fa: Self::Of<'a, A>, ) -> B
where FnBrand: LiftFn + 'a, Self::Index: 'a,

Folds the structure with index by applying a function from right to left. Read more
Source§

fn fold_left_with_index<'a, FnBrand, A: 'a + Clone, B: 'a>( func: impl Fn(Self::Index, B, A) -> B + 'a, initial: B, fa: Self::Of<'a, A>, ) -> B
where FnBrand: LiftFn + 'a, Self::Index: 'a,

Folds the structure with index by applying a function from left to right. Read more
Source§

impl Hash for SendThunkBrand

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, A: 'a> InferableBrand_cdc7cd43dac7585f<'a, SendThunkBrand, A> for SendThunk<'a, A>

Generated InferableBrand_cdc7cd43dac7585f implementation for SendThunk < 'a, A > with brand SendThunkBrand.

Source§

type Marker = Val

Dispatch marker: Val for owned types, Ref for references.
Source§

impl Kind_cdc7cd43dac7585f for SendThunkBrand

Generated implementation of Kind_cdc7cd43dac7585f for SendThunkBrand.

Source§

type Of<'a, A: 'a> = SendThunk<'a, A>

The applied type.
Source§

impl Ord for SendThunkBrand

Source§

fn cmp(&self, other: &SendThunkBrand) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SendThunkBrand

Source§

fn eq(&self, other: &SendThunkBrand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SendThunkBrand

Source§

fn partial_cmp(&self, other: &SendThunkBrand) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl WithIndex for SendThunkBrand

Source§

type Index = ()

The index type for this structure. Read more
Source§

impl Copy for SendThunkBrand

Source§

impl Eq for SendThunkBrand

Source§

impl StructuralPartialEq for SendThunkBrand

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pipe for T

Source§

fn pipe<B>(self, f: impl FnOnce(Self) -> B) -> B

Pipes self into a function, enabling left-to-right composition. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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