forward_goto

Crates.ioforward_goto
lib.rsforward_goto
version0.1.1
sourcesrc
created_at2020-06-04 21:14:37.453143
updated_at2020-06-06 09:15:14.509541
descriptionCrate bringing gotos to Rust.
homepagehttps://crates.io/crates/forward_goto
repositoryhttps://github.com/SrTobi/forward_goto
max_upload_size
id250159
size39,619
Tobias Kahlert (SrTobi)

documentation

README

Build Creates.io Docs

forward_goto

This crate provides a sound and safe way to jump from a goto forward in the control-flow to a label.

use forward_goto::rewrite_forward_goto;

#[rewrite_forward_goto]
fn decode_msg(luck: impl Fn() -> bool, is_alan_turing: bool) {
    if is_alan_turing {
        forward_goto!('turing_complete);
    }

    println!("You'll need a lot of luck for this");
    
    if luck() {
        println!("Seems you were lucky");

        forward_label!('turing_complete);

        println!("Message decoded!");
    } else {
        println!("No luck today...");
    }
}

Should you use it?

Probably not!

Commit count: 12

cargo fmt