reflike

Trait Ref

Source
pub trait Ref<'a, T> {
    // Required method
    fn from_ref(val: &'a T) -> Self;
}
Expand description

A trait for things that are “close enough” to &'a T.

Required Methods§

Source

fn from_ref(val: &'a T) -> Self

Obtains this value from a reference, showing that it’s possible.

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.

Implementations on Foreign Types§

Source§

impl<'a, K, V, R: Ref<'a, K>> Ref<'a, (K, V)> for (R, &'a V)

Pull the key out of a key-value pair.

Source§

fn from_ref(val: &'a (K, V)) -> (R, &'a V)

Source§

impl<'a, T> Ref<'a, T> for &'a T

Identity implementation.

Implementors§

Source§

impl<'a, T: Copy> Ref<'a, T> for T

Values that can be copied can be copied instead of referenced.