Skip to main content

Crate gotobykkrwhofrags

Crate gotobykkrwhofrags 

Source
Expand description

A procedural macro that brings C-style goto to Rust.

Apply goto to any function and use label!(name) and goto!(name) inside its body. The macro rewrites the function at compile time into a state-machine loop — no unsafe, no runtime overhead beyond the loop itself.

Two optional modes are available:

  • #[goto(debug)] — prints jumping to <label> to stdout on every goto!().
  • #[goto(strict)] — turns forward-goto side-effect hazards into compile errors.

Modes may be combined: #[goto(debug, strict)].

§Quick start

use gotobykkrwhofrags::goto;

#[goto]
fn count_up(limit: i32) -> i32 {
    let mut n = 0;
    label!(top);
    n += 1;
    if n < limit { goto!(top); }
    n
}

assert_eq!(count_up(5), 5);

Attribute Macros§

goto
Enables label!(name) and goto!(name) inside a function.