[−][src]Enum cala::Loop
Cala program control flow loop.
Variants
ExitExit the program.
Usage
// Set the home loop to `do_nothing()`. cala::init!(do_nothing, ()); // This program just quits right away. pub fn do_nothing(_: &mut ()) -> cala::Loop<()> { // Exit. cala::Exit }
ContinueKeep the program running.
Usage
// Set the home loop to `infinite_loop()`. cala::init!(infinite_loop, ()); // This program runs until the user interupts it. pub fn infinite_loop(_: &mut ()) -> cala::Loop<()> { // Run this function again. cala::Continue }
BackGo back one activity.
Usage
// Set the home loop to `home()`. cala::init!(home, ()); // This program creates 2 new activities, which both go back right away. pub fn home(_: &mut ()) -> cala::Loop<()> { // `activity_a` is first, because it will be on the top of the activity stack. cala::ReplaceWithBack(activity_a, activity_b) } pub fn activity_a(_: &mut ()) -> cala::Loop<()> { println!("First"); // Go to activity_b cala::Back } pub fn activity_b(_: &mut ()) -> cala::Loop<()> { println!("Last"); // Quit cala::Back }
Append(fn(_: &mut T) -> Loop<T>)Add new activities to the activity stack (new activity loop).
Usage
// Set the home loop to `home()`. cala::init!(home, ()); // Infinite loop. pub fn home(_: &mut ()) -> cala::Loop<()> { // `activity_a` is first, because it will be on the top of the activity stack. cala::Append(activity_a) } pub fn activity_a(_: &mut ()) -> cala::Loop<()> { // Go to activity `home()` cala::Back }
Replace(fn(_: &mut T) -> Loop<T>)Add a new activity to the activity stack (new activity loop), throwing away the one on top (the current activity).
Usage
// Set the home loop to `home()`. cala::init!(home, ()); // This program creates 1 new activity, which quits right away. pub fn home(_: &mut ()) -> cala::Loop<()> { // Replace our `home()` activity with `activity_a()`. cala::Replace(activity_a) } pub fn activity_a(_: &mut ()) -> cala::Loop<()> { // Quit cala::Exit }
ReplaceWithBack(fn(_: &mut T) -> Loop<T>, fn(_: &mut T) -> Loop<T>)Add 2 new activities to the activity stack (new activity loop), throwing away the one on top (the current activity). First parameter is the activity that the user will enter, and the second is the one they will enter when they go back.
Usage
// Set the home loop to `home()`. cala::init!(home, ()); // This program creates 2 new activities, which both go back right away. pub fn home(_: &mut ()) -> cala::Loop<()> { // `activity_a` is first, because it will be on the top of the activity stack. cala::ReplaceWithBack(activity_a, activity_b) } pub fn activity_a(_: &mut ()) -> cala::Loop<()> { println!("First"); // Go to activity_b cala::Back } pub fn activity_b(_: &mut ()) -> cala::Loop<()> { println!("Last"); // Quit cala::Back }
Auto Trait Implementations
impl<T> Sync for Loop<T>
impl<T> Send for Loop<T>
impl<T> Unpin for Loop<T>
impl<T> RefUnwindSafe for Loop<T>
impl<T> UnwindSafe for Loop<T>
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,