Struct illicit::Snapshot[][src]

pub struct Snapshot { /* fields omitted */ }
Expand description

A point-in-time representation of the implicit environment.

Examples

Collecting a Snapshot is useful for debugging:

illicit::Layer::new().offer(5u16).enter(|| {
    println!("{:#?}", illicit::Snapshot::get());
});

Snapshots can also be converted back into Layers for re-use:

let mut snapshot = None;
illicit::Layer::new().offer(5u16).enter(|| {
    assert_eq!(*illicit::expect::<u16>(), 5);
    snapshot = Some(illicit::Snapshot::get());
});
assert!(illicit::get::<u16>().is_err());

illicit::Layer::from(snapshot.unwrap()).enter(|| {
    assert_eq!(*illicit::expect::<u16>(), 5);
});

Implementations

Returns a snapshot of the current context. Suitable for debug printing, or can be converted into a Layer for reuse.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Call op within the context of a Layer containing self.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.