Skip to content

Instantly share code, notes, and snippets.

@gilles-leblanc
Last active August 29, 2015 14:02
Show Gist options
  • Save gilles-leblanc/e07cf10af136c41f37e7 to your computer and use it in GitHub Desktop.
Save gilles-leblanc/e07cf10af136c41f37e7 to your computer and use it in GitHub Desktop.
Rust: expressions
// expressions.rs
fn main() {
let a = {
let inner = 2;
inner * inner
};
println!("a = {}", a);
let b = {
let inner = 2;
inner * inner;
};
println!("b = {}", b);
println!("{}", returns_hello());
let bool_value = true;
let int_value =
if bool_value == true {
1
} else {
0
};
println!("{}", int_value);
}
fn returns_hello() -> String {
String::from_str("hello")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment