I always forget the exact syntax to do shallow clones in git. I recently tracked it down for a few different use cases, so I thought I'd document them in one place since the documentation is kind of diffuse.
This project began the way many of my long Rust articles do-- I got curious about something. I started to wonder a few weeks ago about the relationship between crates that I download from crates.io, and the crate's upstream repository. Here are some of the questions I wanted to answer:
- How do I tell which git commit matches the published crate?
- Is there any guarantee that the published crate source matches the git source?
- What kinds of best practices exist? Is there room for improvement?
I recently became curious about the different tools that are available to do one specific thing in Rust: provide an implementation of the std::io::Write
trait for an in-memory buffer.
This might be useful if you have serializable data that you want to store in a database, or if you want to add checksums or perform compression before storing or sending some data. It may also be useful for buffering ordinary network writes (though BufWriter
might be easier).
How can this be done in Rust? What's the most efficient way of buffering serialized data?
For some reason, I find myself thinking a lot about Rust enums, and matches, and the various ways one can write them.
I admit defeat.
A few weeks ago I was writing some Rust code, building basic data structures from scratch, just for practice and curiosity. At one point I wrote what I thought to be a fairly simple and straightforward function, and discovered that there is no way to convince the borrow checker of its correctness.
I spent a lot of time studying the code and a bunch of variations. After many attempts at fixing it, I am giving up: Rust will not allow this function to compile; the borrow checker wins this time.