Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Promises in a Signature

pub fn arm(&mut self) -> Result<ArmedToken, ArmError>
ElementThe promise
pubThis is API. Callers you can’t see may depend on it.
&mut selfArming changes this object and needs exclusive access.
Result<..>Arming can fail, and the caller must handle that.
ArmedTokenSuccess produces a value that later operations will require.
ArmErrorThe failure modes are enumerated in a type.

Method receivers

ReceiverContract
&selfObservation. No visible state change. Shareable.
&mut selfIn-place modification with exclusive access.
selfConsumption. The value transitions or ends, and its old state can’t be used again.

Generated code rarely uses self by value, but it’s the most useful receiver for design: it makes a state transition irreversible at compile time. The Typestate page builds on this.