The Rust Programming Language
The Rust Programming Language

The Rust Programming Language — Primitives — Summary

Ankit Tanna
Rustaceans
Published in
3 min readOct 10, 2023

--

We’ve seen string, floats, integers and booleans and how they work together. We’ve also seen statements and expressions and subtle rules that Rust Compiler puts in place.

Primitves in Rust
Primitives in Rust

We saw macros like println!(), format!() and panic!() which allow you to log the strings, generate strings and throw an error and stop the program from execution respectively.

We also saw how string interpolation works using {} in Rust.

We came across floats in Rust and mutability concept using mut keyword. By default a float number in Rust would be of type f64.

We came across integers in Rust and by default, Rust would infer an integer to be of type i32.

We also saw typecasting using as keyword and you can typecast from one type to another (generally we do from lower memory type to higher memory type typecasting). When we typecast float to signed or unsigned integer it drops the decimals. So when we typecast 1.99 as u32 the output would be 1.

We also came across booleans where we learnt that Rust compiler recognises only true and false for conditionals and throws a compiler error for truthy…

--

--