Rust learning: lessons, notes, and exercise crates
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/target
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,26 @@
|
||||
fn main() {
|
||||
let mut x = 5;
|
||||
println!("the value of x is {x}");
|
||||
x = 3;
|
||||
{
|
||||
let x = x * 2;
|
||||
println!("The value of x in the inner scope is: {x}");
|
||||
}
|
||||
|
||||
println!("the value of x is {x}");
|
||||
|
||||
const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3;
|
||||
let tup: (i32, f64, u8) = (500, 6.4, 1);
|
||||
|
||||
let (x, y, z) = tup;
|
||||
|
||||
let a: [i32; 5] = [1, 2, 3, 4, 5];
|
||||
let b: [i32; 5] = [0; 5];
|
||||
|
||||
println!("number {}", tup.0);
|
||||
another();
|
||||
}
|
||||
|
||||
fn another() {
|
||||
println!("another one");
|
||||
}
|
||||
Reference in New Issue
Block a user