Skip to content

Commit

Permalink
primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasbs17 committed Jun 20, 2024
1 parent 1ad808f commit 3aa6586
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Binary file added primitives.exe
Binary file not shown.
25 changes: 25 additions & 0 deletions src/primitives.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
fn main() {
// Variables can be type annotated.
let logical: bool = true;

let a_float: f64 = 1.0; // Regular annotation
let an_integer = 5i32; // Suffix annotation

// Or a default will be used.
let default_float = 3.0; // `f64`
let default_integer = 7; // `i32`

// A type can also be inferred from context.
let mut inferred_type = 12; // Type i64 is inferred from another line.
inferred_type = 4294967296i64;

// A mutable variable's value can be changed.
let mut mutable = 12; // Mutable `i32`
mutable = 21;

// Error! The type of a variable can't be changed.
// mutable = true;

// Variables can be overwritten with shadowing.
let mutable = true;
}

0 comments on commit 3aa6586

Please sign in to comment.