Skip to content

Instantly share code, notes, and snippets.

@jbowles jbowles/

Last active Aug 29, 2015
What would you like to do?

I can only rebind a variable that is explicitly declared as mutable; cool.

fn main() {
    let mut x: int = 5;
    x = 10i;
    println!("value of x: {}", x); // -> 10

However, I'm guessing this would be redeclaring the same variable (?), which does NOT trigger a compiler error.

fn main() {
    let x: int = 5;
    println!("value of x: {}", x); // -> 5
    let x: int = 10;
    println!("value of x: {}", x); // -> 10

Is this intentional in Rust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.