Want for intermediate Rust book / docs: a clean cut tutorial on how to implement the Iterator trait. Took a while to figure out that for many cases we need to create a secondary struct that holds / borrows the primary struct and adds a counter / lifetimes. This isn't documented.
-
Show this thread
-
I think a good place to start with is: "Why can we iterate over some structs in Rust's stdlib, whereas for others we need to call `.iter()` before we can iterate over them?" This might be obvious once you understand it, but it can be hard to find out without digging into the src
1 reply 0 retweets 1 likeShow this thread -
yosh Retweeted yosh
Using the terms I wrote about before: - entry level: learn what iterators are and how to use them. - intermediate: learn how to implement iterators for your own types. - seasoned: not sure, haven't hit this point yet.https://twitter.com/yoshuawuyts/status/1006654124505681921 …
yosh added,
yosh @yoshuawuytsI think a lot of "Intermediate Rust" is centered around constructing ergonomic APIs. I think Rust's progression is somewhat like this: - Entry level: learn how to do things. - Intermediate: learn how to do things cleanly. - Seasoned: expand the boundaries of what can be done.Show this thread2 replies 0 retweets 2 likesShow this thread -
Anyway, I've implemented my first, actual iterator! This will allow us to Run Length Encode our bitfields in datrs/hypercore. This implementation will also be more efficient than the JS version because we can keep the pager sparse at all times :Dhttps://github.com/datrs/memory-pager/pull/6/files …
2 replies 0 retweets 2 likesShow this thread
Annnd my second iterator is done! Like really stoked to have this working :D :D https://github.com/datrs/sparse-bitfield/pull/7 …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.