Learning Rust :safe:

IMO expect, unwrap and panic are fine in some cases.

For instance prototype code, so when you are just throwing something together to see if its what you want. No reason to spend any extra time handling errors when you are adding and removing code so frequently.

If a test should fail it’s pretty straight forward to just unwrap or expect things sometimes.

I also sometimes use these as insurance for me as a developer. For instance if I’m doing something where I know that “if this fails, I as a developer has done something wrong in the code, but it should never fail”. Then if I put an expect there I can force the program to crash instead with some useful message. In this case I’m using them for the same reasons asserts are used.

So I’m not of the opinion that they should be avoided at all costs in all cases, I think they have good use cases.


I’ve been learning Rust for a few years and I think it’s the best language.

I tried to get started building something for the SAFE network in Rust in 2018 and 2019, but I couldn’t figure out how to get a basic working application, and I couldn’t find any explanation of the API or examples that I could use as a starting point or anyone with time to help with those things. So instead I decided to commit more fully to a tool I’ve been experimenting with on and off for like 5 years at this point.

I’m working on a node based texture generation tool called Kanter. Have rewritten it at least 4 times trying to find a working architecture, but now the library is working and I’m creating a graphical user interface for it using OrbTk.

Since OrbTk is in development I’m running into bugs and gaps there, and it’s really fun to be able to help them out with reporting bugs, fixing issues I find, adding missing features etc. The maintainer is really welcoming and active, and he’s happy to help anyone who’s running into issues or wanting or trying to contribute, so it’s really fun. Feels like a proper collaboration!

It’s all really hard and really rewarding, and Rust is helping me all along the way.

In C or C++ I would not even dare to try building multi-threaded execution of a directed acyclic graph, which is the core of my application. But thanks to Rust being Rust I have actually done it, to my own astonishment. Rust is literally allowing me to do things that I wouldn’t be able to do otherwise, that’s amazing.

4 Likes