Skip to main content

RefPointed

Trait RefPointed 

Source
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§

Source

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 be Clone.
§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§

Source§

impl RefPointed for CatListBrand

Source§

impl RefPointed for IdentityBrand

Source§

impl RefPointed for LazyBrand<RcLazyConfig>

Source§

impl RefPointed for OptionBrand

Source§

impl RefPointed for Tuple1Brand

Source§

impl RefPointed for VecBrand

Source§

impl<E: 'static> RefPointed for ResultErrAppliedBrand<E>

§Type Parameters
  • E: The error type.
Source§

impl<First> RefPointed for PairFirstAppliedBrand<First>
where First: Monoid + Clone + 'static,

§Type Parameters
  • First: The type of the first value in the pair.
Source§

impl<First> RefPointed for Tuple2FirstAppliedBrand<First>
where First: Monoid + Clone + 'static,

§Type Parameters
  • First: The type of the first value in the tuple.
Source§

impl<Second> RefPointed for PairSecondAppliedBrand<Second>
where Second: Monoid + Clone + 'static,

§Type Parameters
  • Second: The type of the second value in the pair.
Source§

impl<Second> RefPointed for Tuple2SecondAppliedBrand<Second>
where Second: Monoid + Clone + 'static,

§Type Parameters
  • Second: The type of the second value in the tuple.
Source§

impl<T: 'static> RefPointed for ResultOkAppliedBrand<T>

§Type Parameters
  • T: The success type.