Skip to content

SrTobi/forward_goto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

A crate that brings control-flow jumps to Rust

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages