Skip to main content

take_cell_take

Function take_cell_take 

Source
pub fn take_cell_take<'a, P: RefCountedPointer, T: 'a>(
    cell: &P::TakeCellOf<'a, T>,
) -> Option<T>
Expand description

Takes the value out of a take-cell, leaving None behind.

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

§Type Signature

forall P T. RefCountedPointer P => &P T -> Option T

§Type Parameters

  • 'a: The pointer brand.
  • P: The lifetime of the value.
  • T: The type of the stored value.

§Parameters

  • cell: The cell to take the value from.

§Returns

Some(value) if the cell still contains a value, None otherwise.

§Examples

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

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