Function imprint::imprint [] [src]

pub fn imprint<F, R, T>(value: T, callback: F) -> R where
    F: for<'x> FnOnce(Val<'x, T>) -> R, 

Imprint the type of an object with its own value.

A value of type Self is imprinted as Val<'x, Self>, where 'x is a unique marker for this particular value. The callback receives the value as its argument.

Note that the callback isn't allowed to smuggle the imprinted value out of the closure, thanks to the higher-rank trait bound.

See Val for more information.

fn imprint(T, impl for<'x> FnOnce(Val<'x, T>) -> R) -> R

Example

use imprint::{IntoInner, Val, imprint};

imprint(42, |n: Val<i64>| {
    assert_eq!(n.into_inner(), 42);
})