𧡠Understanding @rustlang's newtype idiom, when and how to use it. π
Let's imagine we are building a mini-database for students and professors, here is our starting point.
π
The idea is very simple:
* we keep track of professors using a u32 id
* we keep track of students using a u32 id
We are using a HashMap here, but eventually, this could be a trait with a real database behind it, so the ids are quite important here as this is how we find objects
Jan 6, 2022 β’ 12 tweets β’ 4 min read
𧡠Introduction to @rustlang iterators π¦ π
Iterators are a convenient way to traverse collections. A collection contains multiple elements of the same type (think vector, hashmap, tree, etc.), i.e. it makes sense to traverse it.
Context: I started off with ggez + specs and a very basic understanding of #rustlang and the game I wanted to make. I decided to investigate macroquad+hecs as an alternative and ended up attempting a re-write. This is a thread about my attempt!
βοΈ How much did you actually rewrite vs reuse?
I started with an empty main. I asked myself how each thing was implemented before and if it still made sense. I reused some of the components I had from before but I also changed a lot. Some core ideas stayed and some changed.