Skip to main content

CloseValueRef

Trait CloseValueRef 

Source
pub trait CloseValueRef: Sealed {
    type Closed;

    // Required method
    fn close_ref(&self) -> Self::Closed;
}
Expand description

Close a value without taking ownership

This trait is meant to be used for CloseValue impls for smart-pointer-like types, as in

use metrique::{CloseValue, CloseValueRef};

struct Smaht<T>(T);

impl<T: CloseValueRef> CloseValue for &'_ Smaht<T> {
    type Closed = T::Closed;
    fn close(self) -> T::Closed { self.0.close_ref() }
}

impl<T: CloseValueRef> CloseValue for Smaht<T> {
    type Closed = T::Closed;
    fn close(self) -> T::Closed { self.0.close_ref() }
}

This trait is not to be implemented or called directly. It mostly exists because it makes trait inference a bit smarter (it’s also not a full trait alias due to trait inference reasons).

Required Associated Types§

Source

type Closed

The type produced by closing this value

Required Methods§

Source

fn close_ref(&self) -> Self::Closed

Close the value

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C, T> CloseValueRef for T
where for<'a> &'a Self: CloseValue<Closed = C>,