5
Reading Club: The Book Chs 5 & 6 "Structs and Enums" [PROJECT]
(rust-book.cs.brown.edu)
A collaborative space for people to work together on learning Rust, learning about the Lemmy code base, discussing whatever confusions or difficulties we're having in these endeavours, and solving problems, including, hopefully, some contributions back to the Lemmy code base.
Rules TL;DR: Be nice, constructive, and focus on learning and working together on understanding Rust and Lemmy.
See also:
Thumbnail and banner generated by ChatGPT.
The classical one is something that looks like the following:
This would prevent you from writing code that uses the user's info / session "object" after they have logged out (and/or before they have logged in). On its own it's naive and a bit encumbering - I expect an enum would make more sense but then you can't restrict via types which user session values can and can't be passed to specific functions. In any case, when you are building a whole system around it it can be very useful to have the compiler enforcing these sorts of things "in the background".
This is basically what Gary Bernhardt is talking about in the talk you linked.
Yep. And then you realise that "move semantics" aren't just a safety net that you have to "fight with" but actually a language feature against which you can develop/deploy desirable patterns.
A minor thing I noted reading your code snippets was that I immediately noticed, like at a gestalt level, the lack of ampersands (
&) and therefore references and could immediately tell that this was a "faux-O"/pipline style system. Not too bad for a syntax often derided as messy/bad.