pub trait RefPointed: Kind_cdc7cd43dac7585f {
// Required method
fn ref_pure<'a, A: Clone + 'a>(
a: &A,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>;
}Expand description
A type class for contexts that can be initialized from a reference.
The Clone bound on A is required because constructing an owned
Of<A> from &A inherently requires cloning. This is the only
by-reference trait with a Clone bound; all other by-ref traits
pass &A to a user-supplied closure, letting the user control
whether cloning happens.
Required Methods§
Sourcefn ref_pure<'a, A: Clone + 'a>(
a: &A,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn ref_pure<'a, A: Clone + 'a>( a: &A, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
Wraps a cloned value in the context.
§Type Signature
forall A. &A -> Self A
§Type Parameters
'a: The lifetime of the value.A: The type of the value to wrap. Must beClone.
§Parameters
a: A reference to the value to wrap.
§Returns
A new context containing a clone of the value.
§Examples
use fp_library::{
brands::*,
classes::*,
types::*,
};
let value = 42;
let lazy = LazyBrand::<RcLazyConfig>::ref_pure(&value);
assert_eq!(*lazy.evaluate(), 42);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl RefPointed for CatListBrand
impl RefPointed for IdentityBrand
impl RefPointed for LazyBrand<RcLazyConfig>
impl RefPointed for OptionBrand
impl RefPointed for Tuple1Brand
impl RefPointed for VecBrand
impl<E: 'static> RefPointed for ResultErrAppliedBrand<E>
§Type Parameters
E: The error type.
impl<First> RefPointed for PairFirstAppliedBrand<First>
§Type Parameters
First: The type of the first value in the pair.
impl<First> RefPointed for Tuple2FirstAppliedBrand<First>
§Type Parameters
First: The type of the first value in the tuple.
impl<Second> RefPointed for PairSecondAppliedBrand<Second>
§Type Parameters
Second: The type of the second value in the pair.
impl<Second> RefPointed for Tuple2SecondAppliedBrand<Second>
§Type Parameters
Second: The type of the second value in the tuple.
impl<T: 'static> RefPointed for ResultOkAppliedBrand<T>
§Type Parameters
T: The success type.