take

Function take 

Source
pub fn take<Brand: ThunkWrapper, T>(cell: &Brand::Cell<T>) -> Option<T>
Expand description

Takes the value out of the cell.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall a. Cell a -> Option a

§Type Parameters

  • Brand: The pointer brand.
  • T: The type of the value.

§Parameters

  • cell: The cell to take the value from.

§Returns

The value if it was present, or None.

§Examples

use fp_library::{brands::*, functions::*};

let cell = thunk_wrapper_new::<RcBrand, _>(Some(42));
assert_eq!(thunk_wrapper_take::<RcBrand, _>(&cell), Some(42));
assert_eq!(thunk_wrapper_take::<RcBrand, _>(&cell), None);