From 278ec88944aa138e564cf9158c049f95251301d2 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 12 Sep 2021 10:35:45 -0400 Subject: [PATCH] RBE custom types constants --- .../custom_types/custom_types_constants.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rustbyexample/custom_types/custom_types_constants.rs diff --git a/rustbyexample/custom_types/custom_types_constants.rs b/rustbyexample/custom_types/custom_types_constants.rs new file mode 100644 index 0000000..85e6426 --- /dev/null +++ b/rustbyexample/custom_types/custom_types_constants.rs @@ -0,0 +1,16 @@ +static LANGUAGE: &str = "Rust"; +const THRESHOLD: i32 = 10; + +fn is_big(n: i32) -> bool { + n > THRESHOLD +} + +fn main() { + let n = 16; + + println!("This is {}", LANGUAGE); + println!("The threshold is {}", THRESHOLD); + println!("{} is {}", n, if is_big(n) { "big" } else { "small" }); + + // THRESHOLD = 5; +}