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 = "function"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "function"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,29 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
let y = {
|
||||
let x = 3;
|
||||
x + 1
|
||||
};
|
||||
|
||||
println!("The value of y is: {y}");
|
||||
|
||||
another_function(32, 'a');
|
||||
let z = five();
|
||||
println!("the value of z is {z}");
|
||||
|
||||
let x = plus_one(5);
|
||||
println!("the value of x is {x}")
|
||||
}
|
||||
|
||||
fn another_function(a: usize, b: char) {
|
||||
println!("Another function. {a}, {b}");
|
||||
}
|
||||
|
||||
fn five() -> i32 {
|
||||
5
|
||||
}
|
||||
|
||||
fn plus_one(x: i32) -> i32 {
|
||||
x + 1
|
||||
}
|
||||
Reference in New Issue
Block a user