rust-learnings icon indicating copy to clipboard operation
rust-learnings copied to clipboard

Collection of Rust learnings through implementation

Rust learnings

Projects

  • Smart Pointers
  • Procedural macros workshop
  • Procedural macros playground
  • Channels

Smart pointers

Implementation of std::cell, std::cell::RefCell and std::rc::Rc.
This was done following a great Crust of Rust on Smart Pointers and Interior Mutability by Jon Gjengset (@jonhoo).

Project under smart-pointers.

Procedural macros workshop

Started working on this workshop for Rust Latam by David Tolnay (@dtolnay).
Also inspired by a long session on proc macros by Jon Gjengset (@jonhoo)!

Progress

  • [x] Derive macro: derive(Builder)
    • Source: proc-macro-workshop/builder/src/lib.rs
  • [x] Derive macro: derive(CustomDebug)
    • Source: proc-macro-workshop/debug/src/lib.rs
  • [x] Function-like macro: seq!
    • Source: proc-macro-workshop/seq-impl/src/lib.rs
  • [x] Attribute macro: #[sorted]
    • Source: proc-macro-workshop/sorted/src/lib.rs
  • [x] Attribute macro: #[bitfield]
    • Source: proc-macro-workshop/bitfield/impl/src/lib.rs and proc-macro-workshop/bitfield/src/lib.rs

Project under proc-macro-workshop.

Procedural macros playground

Toy repo to do some tests on proc macro syntax.

Project under proc-macro-playground.

Channels

Another great Crust of Rust.

Implementation of std::sync::mpsc::channel in eurostar/src/lib.rs.

This is a simple implementation of asynchronous/unbounded multi-producer single consumer (mpsc) channel using a VecDeque buffer, a Mutex and a Condvar behind an Arc.

Project under eurostar.