Member-only story
Rust: Strings, Loops, Conditional statements Basics — A Practical Guide
An In-Depth Guide to Data Types in Rust
Understanding Rust's Robust Type System
rohitsaroj7.medium.com
Hello Codes! 👋🐍 Welcome back to our exploration of Rust. In our previous blog, we deep dived into Rust’s data types, and now it’s time to roll up our sleeves and get hands on with the language’s core syntax, will also compare it with Python syntax. No frills, just practical insights to make your transition smoother. 🚀🦀
1. Assigning Variables and Handling Strings 📝
In Rust, variable assignment and string handling are straightforward yet fine. Let’s break it down:
Rust
let name = String::from("Pythonista");
let age = 28;
println!("Hello, I'm {} and I'm {} years old!", name, age);
- Here, we declare a string variable ‘name’ and an integer variable ‘age’.
- The ‘println!’ macro prints a formatted string using these variables.
- Rust’s ownership system ensures memory safety without sacrificing…