Technically this may be more like day 8 or 9, cause I did read some stuff from the rust book in last few days, and made note here
Nothing improves your understanding better than doing
– Me 😄
I was trying accessing the individual fields in tuple struct using dot notation via the index
Since the rust book does not have an example of it, I used rust playground (Awesome resource BTW) and just printed stuff.
Continue Reading »
When I started reading about Ownership, I was thinking
I have done C. I understand memory
But Rust book explains :
If you are familiar with systems programming, you might think of memory at a low level like “memory is an array of bytes” or “memory is the pointers I get back from malloc”. .. The low-level model is too concrete to explain how Rust works. Rust does not allow you to interpret memory as an array of bytes, for instance.
Continue Reading »
I want to access Bard API via Rust, but it will take some time.
Here are the things I did today.
First, I tried (successfully) to access an URL via Rust code. ✅
I used the reqwest module.
I just added this dependency in my Cargo.toml and (like in other languages) the dependency hell was let loose 😄
67 other modules were added to the Cargo.lock!
I also learnt to use global variables in Rust.
Continue Reading »
Started with (optional) assignment at the end of “Programming Concept” chapter : Convert temperature between Celsius and Fahreinheit. 1
Since the algorithm itself is not part of the learning the language, I asked Google Bard about the formula.
It was nice working on some code after a while (Aside from work, I mean)
Once again, I realized that compiler is very helpful 😍
I started simple.
Breaking down functionality into smaller functions.
Continue Reading »
Today I finished Functions and Control Flow etc.
While these are not new “concepts” for me, one always learns something new when learning a new language.
Two things I learnt:
I liked the fact that rust does not evaluate anything other than boolean as truthy like both python and ruby loop can have labels, and can be used with break and continue to indicate where should the execution continue
Today I started with Data Types
While most of it is intuitive, it is useful to go over the documentation.
e.g. For tuple, I had expected that to access specific index, syntax would be mytuple[0]. mytuple.0 was not I had expected.
I also tried to print the tuple.
In the process, I learnt about pretty printing only from the compiler errors.
The compiler errors are so descriptive 😍
Here is the code in case you are interested
Continue Reading »
Today I finished the Number guessing game
During the early part of the code, my mind started thinking “How will comparing string input from the user, work with a number? 🤔” (💪 of having gone through such issues numerous times over the years)
Of course, it was explained later.
I was a bit disappointed that the code paniced upon entering non-number 😞 especially after the expect clause.
Turns out that is expected behaviour.
Continue Reading »
In this new year, I have decided to learn rust
All my recent experience has been in dynamic languages (90% python, 10% ruby)
But I started my software development career in C, and did that for probably 10 years. So I’m not new to compiled languages.1 But things have changed a lot (for the better) in these years.
Additionally, rust is getting a lot of attention from bigwigs like MS.
Continue Reading »