Skip to main content

create_state

Macro create_state 

Source
macro_rules! create_state {
    ($self:ident, $type:ty, $body:expr) => { ... };
}
Expand description

Macro for implementing create_state_boxed() with automatic TypeId inference.

The $body expression receives the capability instance via $self and can use ? for fallible operations.

§Example

impl HostCapability for MyCapability {
    // ...
    create_state!(this, MyState, {
        MyState {
            shared_resource: this.get_resource(),
            counter: 0,
        }
    });
}