Rust crates worth reading? prefer < 2k loc; hard limit < 5k loc

  1. If something like this already exists, please point me there.

  2. This is meant to be in the spirit of , except in Rust, with < 2k loc preferred, 5k hard limit.

  3. We can count lines of code via 'cloc' (or latest tooling).

  4. If learned alot from readintg the source code of a trait, please post a link below (with a short description of what you learned / how it leveld up your programming skills).

  5. Main focus is on what you learned from te crate (rather than whether you would use the crate in production) -- so please feel free to list crates that are a "toy implementation" of FOO, but happens to be very well written and instructive.



I'd shameless-ly plug one my own crates, since its purpose was kind of going in that direction:

  • Note that since March or something like that, mini_paste does not offer any real feature over ::paste (not even compile-time), since at that point even ::paste stopped depending on ::syn/::quote.

That being said, it's around a 3-4 hundrer lines of code at most, and it does show how to:

  • setup a procedural macro crate with the front-end / back-end pattern;

  • with no ::syn nor ::quote;

  • and nevertheless feature forging new idents with a procedural macro (in this case, concatenating idents).


That's a very broad request. Are there things you don't want? I feel like it wouldn't help you, if I dropped a link to my atomic cell code, next week, after finishing the prototype + documenting it. It features atomics and unsafe. It's going to be a small library, but also heavy to digest for beginners.


Also, although it is not really one crate, and it may be, in total, more lines than what you were asking for, I find that @anon15139276's blog post series from building your own async executor to its (comparatively) simple ::smol async framework, to be really interesting.

For some reason, though, the blog posts are no longer available (the reason I am trying to ping their author within this very post).

That being said, Internet being what it is, we got snapshots :grin::

  1. Build your own block_on,

  2. Build your own executor,

  3. Why [they are] building a new async runtime [(smol)].

1 Like

I would recommend people err on the side of posting too many crates because:

  1. even if it is not interesting ot me, it might be interesting to someone else

  2. ignoring personally un-interesting crates is easier than finding interesting crates; I am perfectly happy skimming 50 crate github links for every crate where I read the source in detail

  3. so if you think there is even a 2% chance there is something worth learning from, I would recommend posting it

1 Like
  • nginee (1.2k LOC) is something cooked up to support:
    • async, wasm, and winit together
    • shows testing of features in a workspace
1 Like

A somewhat old crate from Niko, but shows that graphs in rust doesn't have to be a painful experience at sub 100 LOC.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.