[][src]Struct revent::Slot

pub struct Slot<T: ?Sized> { /* fields omitted */ }

Container for a single optional Node.

Useful for providing a container that may be empty. If the item is always supposed to exist then using Node directly is more useful.

use revent::{Node, Slot};

let mut slot = Slot::new();

slot.insert(Node::new(123));

let result: i32 = slot.emit(|x| {
    println!("{}", x);
    *x + 1
});

println!("{}", result);

Implementations

impl<T: ?Sized> Slot<T>[src]

pub fn new() -> Self[src]

Create a new slot.

pub fn new_with_trace(trace: impl Fn(usize) + 'static) -> Self[src]

Create a new channel with a trace object.

pub fn insert(&mut self, item: Node<T>)[src]

Insert a node into this slot.

Panics

Panics if there already exists a node in this slot.

pub fn remove(&mut self) -> Node<T>[src]

Remove the currently held node from this slot.

Panics

Panics if there exists no node in this slot.

pub fn emit<R>(&self, handler: impl FnOnce(&mut T) -> R) -> R[src]

Apply a function to the node in this slot.

Panics

Panics if there exists no node in this slot.

Trait Implementations

impl<T: ?Sized> Default for Slot<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Slot<T>

impl<T> !Send for Slot<T>

impl<T> !Sync for Slot<T>

impl<T: ?Sized> Unpin for Slot<T>

impl<T> !UnwindSafe for Slot<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Suspend for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.