I continued reading Command Line Applications in Rust
Learnt that testing is easy. Any function that has #[test] above it, will be found (across any files) and used by cargo test
Couple of interesting crates :
exitcode It has quite well defined exit codes. They come from FreeBSD I wish other languages / frameworks had something similar proptest is a property testing framework Based on python’s Hypothesis I need to spend time actually trying this human-panic Generates report file on panic Shows nice (if a bit long) message to the user, asking them to (optionally) email the report file to the developer 🤯 Things to explore:
Today I started reading Command Line Applications in Rust
Even though I have not finished reading “the book”, I am (by now) familiar with enough rust code that reading this book was kinda refreshing.
Few important things I picked up :
{:?} in println! is called debug representation (quite useful for .. debugging 😄) Custom data types can add support for {:?} for debugging and logging, one needs to add a #[derive(Debug) above their definition.
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.
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.
I wrote about logseq almost two years ago and then I think when I switched job, I stopped using logseq.
When I updated macOS, I forgot to install it, and forgot about it overall (I started using denote - in Emacs for some time)
Recently when I started using obsidian while trying l learn more about it, I came across logseq again.
I tried it again (after 2 years)
I spent time learning basics (again)
Yesterday, I was trying to access Bard API via Rust
The task is WIP because :
I’m still learning Rust (Although on Day 5 I was able to access a URL from rust code) I didn’t know how to access Bard API It started with a Youtube video that:
Uses python code which uses Bard library Not sure if it is official one or third party one In either case it won’t be directly useful in rust code Uses a hack to get session cookie from browser (which will expire sooner or later) At that time, I didn’t know whether Google has made Bard API accessible via an API
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.
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.