Wikipedia

Search results

08 November 2019

Global Constants in Rust

It's really straight forward.

static WORLD: &'static str = "Foo";
static NUMBA: i32 = 143;

fn main() {
    // Access constant in the main thread
    if NUMBA > 0 {
        println!("Hello {}", WORLD);
    }
}

outputs:

$ ./target/debug/js_stack
Hello Foo

No comments:

Post a Comment