My first day of learning Rust πŸ¦€

Documentation of learning Rust
rust
notes
Published

November 29, 2022

Keywords

programming, coding, rust

I have been using Python since my college (2018), it has allowed me to experiment my ideas quickly without worrying a lot about syntax and data structures. I could quickly implement complex algorithm and do some operations in a single line that would take more than 3 LOC in other languages like Java.

# swapping variable in Python
a = 1
b = 2

a, b = b, a

Today, I am learning Rust. I am particularly interested in this programming language because of its use cases in wide areas like optimized image resize and creating optimized programs and binding it with other language like Python.

Now let’s talk about Rust πŸ¦€

How to create a dynamic string?

We can compare it with Python staticmethod SomeClass.somemethod, with :: instead of ..

The double colon :: operator allows us to namespace this particular from function under the String type rather than using some sort of name like string_from. (source)[https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html#the-string-type]

let s = String::from("hello");

This string is mutable and to add more characters we can do the following -

    s.push_str(", world!");