You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ui.label("Cool Floating Rustacean in an egui::Area. Areas are dragable, click the center and hold and drag area around to desired position. egui::Area itself does not directly control its size — it wraps content and takes the size of whatever UI elements are inside it.");
ui.label("Cool Floating Rustacean in an egui::Area. Areas are dragable, Drag and Reposition an Area using the 'Rustferris' image in the top left of each area, or anywhere else on an Area it seems! just not on text. The position of an area persists from where it was last dragged and positioned. click the center and hold and drag area around to desired position. egui::Area itself does not directly control its size — it wraps content and takes the size of whatever UI elements are inside it.");
// This code would not compile, because by default, variables are immutable, and as the RustBook states, 'When a variable is immutable, once a value is bound to a name, you cant change that value.'
8
+
8
9
fn main() {
9
10
let x = 5;
10
11
println!("The value of x is: {x}");
11
12
x = 6;
12
13
println!("The value of x is: {x}");
13
14
}
14
15
15
-
// Good code that would compile bc value is declared mutable,
16
+
// In the provided Rust example, a compilation error would occur because the code attempts to assign a new value to an 'immutable variable `x`', which is not allowed in Rust by default.
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
57
+
Running `target/debug/variables`
58
+
The value of x is: 5
59
+
The value of x is: 6
60
+
61
+
Why This Matters:
62
+
63
+
* Rust enforces `immutability by default` to prevent bugs that arise from unexpected value changes.
64
+
* This makes code more predictable and easier to debug, especially in concurrent or complex systems.
65
+
* If you need to change a variable, explicitly marking it as mutable (`mut`) signals that intent to other developers.
66
+
67
+
// Takeaway:
68
+
// Compiler errors in Rust are designed to help you write **safe and correct code**. Even experienced developers encounter them — they’re part of the learning process and a core strength of Rust's safety guarantees.
69
+
70
+
**Constants**
71
+
72
+
// Constants are values bound to a name and are not allowed to change, similar to immutable variables. There are differences though between constants and variables, so lets take a look.
There is one of the most important funtions, the 'main' function.
208
+
There is one of the most important funtions, the 'main' function, the entry point of many programs. In RUST we use the fn keyword to allow us to declare new functions.
209
+
210
+
For function and variable names, RUST uses snake case, where all letters are lowercase and underscores seperate words. example_snake_case
0 commit comments