值(如文本)可以綁定變量,使用 let 綁定。

fn main() {
let an_integer = 1u32;
let a_boolean = true;
let unit = ();

// copy \`an\_integer\` into \`copied\_integer\`
let copied\_integer = an\_integer;

println!("An integer: {:?}", copied\_integer);
println!("A boolean: {:?}", a\_boolean);
println!("Meet the unit value: {:?}", unit);

// The compiler warns about unused variable bindings; these warnings can
// be silenced by prefixing the variable name with an underscore
let \_unused\_variable = 3u32;

let noisy\_unused\_variable = 2u32;
// FIXME ^ Prefix with an underscore to suppress the warning