I know this is a small point, but you likely mean "race condition" here. Rust already guarantees safe code to be free of "data races", and this blog post doesn't discuss unsafe in any way.
Two other points that came up while I was reading:
1. I get that this is something you did once for an internal project, but this is what macros and derive_macros are made for.
2. The AI that you used to help write the post left its mark a little too deep. The cliched phrases make an appearance at the start of every section and it really starts to grate by the end.
You're right about the terminology, my title oversells it. There's actually no concurrent mutation at all: each reducer reads the shared state and returns a fresh slice, and the pieces are stitched back together after. What the compile-time check really guarantees is that every state slice has exactly one reducer. That's what makes running them in parallel safe without a lock.
1. Well no actually, the internal project was in Python, I wanted a playground project inspired by my experience to learn Rust. On macros: I know derive could cut the boilerplate, but I wanted to understand the underlying mechanism first, so I wrote the type-level part by hand. The compile-time guarantee comes from those bounds, not from the macro, so learning that part felt more useful than hiding it. Derive is on my list for later.
2. On the writing: I drafted with Claude (noted at the bottom of the post) and I agree that I didn't edit the tone down enough. Not an excuse, but with a full-time job and two kids I'd rather spend my time on the ideas than the prose. I'll be more careful next time.
6 comments
[ 2.6 ms ] story [ 22.0 ms ] threadIf you don’t have time to write, I don’t have time to read it.
Two other points that came up while I was reading:
1. I get that this is something you did once for an internal project, but this is what macros and derive_macros are made for.
2. The AI that you used to help write the post left its mark a little too deep. The cliched phrases make an appearance at the start of every section and it really starts to grate by the end.
1. Well no actually, the internal project was in Python, I wanted a playground project inspired by my experience to learn Rust. On macros: I know derive could cut the boilerplate, but I wanted to understand the underlying mechanism first, so I wrote the type-level part by hand. The compile-time guarantee comes from those bounds, not from the macro, so learning that part felt more useful than hiding it. Derive is on my list for later.
2. On the writing: I drafted with Claude (noted at the bottom of the post) and I agree that I didn't edit the tone down enough. Not an excuse, but with a full-time job and two kids I'd rather spend my time on the ideas than the prose. I'll be more careful next time.