pub struct RunBuilder<'a, N, F = CliFrontend>{ /* private fields */ }Expand description
A builder that runs the narrative when it is dropped
Implementations§
Source§impl<'a, N, F> RunBuilder<'a, N, F>
impl<'a, N, F> RunBuilder<'a, N, F>
Sourcepub fn command<C, G>(self, names: C, command: G) -> Self
pub fn command<C, G>(self, names: C, command: G) -> Self
Add a global command to the Runtime
Global commands can always be entered by the user.
Some examples of global commands might be:
- save
- inventory / inv
- look around
Examples found in repository?
examples/rooms.rs (lines 110-116)
104fn main() {
105 run(
106 Room::Start,
107 &mut State { has_key: false },
108 &mut CliFrontend::new(),
109 )
110 .command("save", |rt| {
111 match rt.save("rooms.yaml") {
112 Ok(_) => rt.println("Save complete"),
113 Err(e) => rt.println(format!("Error: {}", e)),
114 }
115 Continue
116 })
117 .command("load", |rt| {
118 match rt.load("rooms.yaml") {
119 Ok(_) => rt.println("Load complete"),
120 Err(e) => rt.println(format!("Error: {}", e)),
121 }
122 Skip
123 })
124 .command("inv, inventory", |rt| rt.push_node(Inventory));
125}Trait Implementations§
Auto Trait Implementations§
impl<'a, N, F> Freeze for RunBuilder<'a, N, F>
impl<'a, N, F = CliFrontend> !RefUnwindSafe for RunBuilder<'a, N, F>
impl<'a, N, F = CliFrontend> !Send for RunBuilder<'a, N, F>
impl<'a, N, F = CliFrontend> !Sync for RunBuilder<'a, N, F>
impl<'a, N, F> Unpin for RunBuilder<'a, N, F>
impl<'a, N, F = CliFrontend> !UnwindSafe for RunBuilder<'a, N, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more