Trait frunk_core::traits::ToRef[][src]

pub trait ToRef<'a> {
    type Output;
    fn to_ref(&'a self) -> Self::Output;
}

An alternative to AsRef that does not force the reference type to be a pointer itself.

This lets us create implementations for our recursive traits that take the resulting Output reference type, without having to deal with strange, spurious overflows that sometimes occur when trying to implement a trait for &’a T (see this comment: https://github.com/lloydmeta/frunk/pull/106#issuecomment-377927198)

This functionality is also provided as an inherent method on HLists and on Coproducts. However, you may find this trait useful in generic contexts.

Associated Types

Loading content...

Required methods

fn to_ref(&'a self) -> Self::Output[src]

Loading content...

Implementors

impl<'a> ToRef<'a> for CNil[src]

type Output = CNil

impl<'a> ToRef<'a> for HNil[src]

type Output = HNil

impl<'a, CH: 'a, CTail> ToRef<'a> for Coproduct<CH, CTail> where
    CTail: ToRef<'a>, 
[src]

type Output = Coproduct<&'a CH, <CTail as ToRef<'a>>::Output>

impl<'a, H, Tail> ToRef<'a> for HCons<H, Tail> where
    H: 'a,
    Tail: ToRef<'a>, 
[src]

type Output = HCons<&'a H, <Tail as ToRef<'a>>::Output>

Loading content...