pub enum State<T = ()> {
Off,
On(Option<T>),
}
Expand description
Represents an on/off state, optionally carrying additional data when on.
§Type Parameters
T - The type of additional data carried when in the On state. Defaults to ().
§Variants
Off - The switch is turned off.
On(Option<T>) - The switch is on, optionally with additional data.
Creates a new State in the On position with no additional data.
§Returns
A State in the On position with None data.
Creates a new State in the Off position.
§Returns
A State in the Off position.
Returns true if the state is Off.
§Returns
true if Off, false otherwise.
Returns true if the state is On.
§Returns
true if On, false otherwise.
Toggles between On and Off, clearing any additional data.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
[From]<T> for U chooses to do.
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.