Skip to main content

cloneable_new

Function cloneable_new 

Source
pub fn cloneable_new<'a, P: RefCountedPointer, T: 'a>(
    value: T,
) -> P::CloneableOf<'a, T>
where P::CloneableOf<'a, T>: Sized,
Expand description

Wraps a sized value in a cloneable pointer.

§Type Signature

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

§Type Parameters

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

§Parameters

  • value: The value to wrap.

§Returns

The value wrapped in the cloneable pointer type.

§Examples

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

let ptr = ref_counted_pointer_new::<RcBrand, _>(42);
let clone = ptr.clone();
assert_eq!(*clone, 42);