Stainless

Tagged in

linebyline

Bitflags 1.0.1 - Part 3

This is part three in the series of breaking down the rust crate Bitflags. If you haven’t already, go read part one and page two And lastly, we are on to the most obtuse bit of the entire crate, which arguably I still don’t fully understand, but let’s dive in to see. Let’s start with the chunk of comment that explains what this macro does at the high level because it sets the context pretty well....

Bitflags 1.0.1 - Part 2

This is part two in the series of breaking down the rust crate Bitflags. If you haven’t already, go read part one Let’s look at what __impl_bitflags! does. macro_rules! __impl_bitflags { ( // Pattern matching omitted ) => { impl $crate::_core::fmt::Debug for $BitFlags { fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { First up, it implements the ability to debug/format the struct into a nice enough string, but first, as explained in the comment in the original code, the code needs to do some convoluted things to handle flags that are omitted conditionally, so let’s walk through that....

Bitflags 1.0.1 - Part 1

The Line by Line series will be an in-depth look at Crates in the Rust ecosystem. It’s an attempt for me to get a better understanding of Rust by looking at real work examples and explaining what they do. I am far from a competent rust programmer, so if I get something wrong, please leave a comment with the corrections and I’ll update the posts based on your feedback with appropriate edit credits....