Rust Programming Language - Primitive types

Voctl
1 min read

first of all i learned smth like there is no default mutable variable in Rust.
You must write smth like "let mut x = 5;"
and the second one is bro, rust have dynamic arrays...damn bro its python or what bro what is dynamic arrays bro i ll cry :sob: (yk)
So its the primitve types in Rust programming languages;

// the primitive types in Rust programming language

fn main() {
// integer
let sum = 5 + 10;
println!("{}", sum);

//char
let heart_eyed_cat = '😻';
println!("{}", heart_eyed_cat);

//bools
let t = true;
let f: bool = false;
println!("{}\n{}", t, f);

//tuples
let tup: (u32, u64, char) = (500, 600, 's');
println!("{:?}", tup);
//acces to element of a tuple
let tup1 = tup.1;
println!("{}", tup1);
//bacarrame

//arrays and yes Rust have dynamic arrays and its so basic

let _xs = [1, 2, 3, 4, 5];
/*You write an array’s type using
 * square brackets with the type of each element,
 * a semicolon, and then the number of
 * elements in the array, like so:*/

let smthn : [i32; 5] = [1, 2 , 3, 4, 5];
println!("{:?}", smthn);
println!("{:?}", _xs);
}

2

Responses (2)

Sign in to leave a response.

  • Yusif Aliyev

    > let x mut = 5; It should actually be `let mut x = 5;`. But yes, I was also confused at first. In TypeScript, `let` itself means mutable, while `const` is immutable (primitive types/references are immutable, object and array values can be reassigned).