rustlings vec primitive types

This commit is contained in:
2026-06-12 12:05:51 +02:00
parent 7b26706218
commit 85c0fb50cb
215 changed files with 4435 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
fn main() {
// Declaring variables requires the `let` keyword.
let x = 5;
println!("x has the value {x}");
}
+16
View File
@@ -0,0 +1,16 @@
fn main() {
// The easiest way to fix the compiler error is to initialize the
// variable `x`. By setting its value to an integer, Rust infers its type
// as `i32` which is the default type for integers.
let x = 42;
// But we can enforce a type different from the default `i32` by adding
// a type annotation:
// let x: u8 = 42;
if x == 10 {
println!("x is ten!");
} else {
println!("x is not ten!");
}
}
+4
View File
@@ -0,0 +1,4 @@
fn main() {
// DON'T EDIT THIS SOLUTION FILE!
// It will be automatically filled after you finish the exercise.
}
+4
View File
@@ -0,0 +1,4 @@
fn main() {
// DON'T EDIT THIS SOLUTION FILE!
// It will be automatically filled after you finish the exercise.
}
+9
View File
@@ -0,0 +1,9 @@
fn main() {
let number = "T-H-R-E-E";
println!("Spell a number: {number}");
// Using variable shadowing
// https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing
let number = 3;
println!("Number plus two is: {}", number + 2);
}
+4
View File
@@ -0,0 +1,4 @@
fn main() {
// DON'T EDIT THIS SOLUTION FILE!
// It will be automatically filled after you finish the exercise.
}