It is recommended to split a huge Rust project into crates and manage them in a workspace. I’m currently working on a project which consists of about 60 crates. It works well so far until I try to publish these crates to crates.io. I will list the problems I have met and solutions or workarounds I have adopted.
A collection of 4 articles
Pin is an obscure type in Rust because of the naming and indirect concepts. The first indirect concept is pointer. Pin<X> does not guarantee that X will not move. If X is a pointer which target type is T, Pin<X> guarantees that T will not move. The second is “not move”. It really means that the only way to get the mut reference to T is via unsafe interface. The last is the Unpin mark trait. Pin forbids safe interface to get the mut reference to T only when T is !Unpin. In simple words, Pin is a pointer wrapper. When a pointer is trapped inside Pin, and the pointee type is !Unpin, there’s no safe way to get a mut reference to the pointee.
How to mock time in Rust tests and Cargo gotchas we met. I’m working in a team developing a big Rust project recently. The project has some features depending on time. We, the developers, want to be able to mock the time in the test. In this post, I’ll talk about the problems we have met, mostly related to Cargo.
In Rust document, Cell is “A mutable memory location”, and RefCell is “A mutable memory location with dynamically checked borrow rules”. They both provide “interior mutability”, where you can modify the value stored in cell via immutable reference of the cell. They both have an API get_mut to return a mutable reference to the underlying data. This method requires a mutable reference to the cell, which guarantees that the callee has exclusive ownership of the cell. pub fn get_mut(&mut self) -> &mut T The difference is how they implement interior mutability. Cell copies or moves contained value, while RefCell allows both mutable and immutable reference borrowing. I will try to explain the difference via their APIs in this article.