Member-only story

Rust: Strings, Loops, Conditional statements Basics — A Practical Guide

Strings, Loops, Conditional statements

Yash
4 min readJan 15, 2024
By author

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…

--

--

Yash
Yash

Written by Yash

I'm a Data Scientist & Renewable Energy geek 🌱 Exploring Data📊, Green tech🌍, and Innovation💡 Hope to write on Data Science, Life, & Everything in between ;)

No responses yet