[…] >> >> >> Because it is not as explicit. The main thing we should be conveying to users >> here is how to get a &mut or otherwise mutate the data when running the >> handler. When people see AtomicU32, it's a quick jump to "I can make this work >> by using other locks, like SpinLockIrq". Completions hide this, IMHO. >> > > I understand your argument. However, I'm not sure the example of > `irq::Registration` is the right place to do this. On one hand, it's one > of the usage of interior mutability as you said, but on the other hand, > for people who are familiar with interior mutability, the difference > between `AtomicU32` and `Completion` is not that much. That's kinda my > argument why using `Completion` in the example here is fine. > > Sounds reasonable? > >> It's totally possible for someone to see this and say "ok, I can call >> complete() on this, but how can I mutate the data in some random T struct?", >> even though these are essentially the same thing from an interior mutability >> point of view. >> > > We probably better assume that interior mutability is commmon knowledge > or we could make an link to some documentation of interior mutability, > for example [1], in the documentation of `handler`. Not saying your > effort and consideration is not valid, but at the project level, > interior mutability should be widely acknowledged IMO. > > [1]: https://doc.rust-lang.org/reference/interior-mutability.html > > Regards, > Boqun > >> -- Daniel I do expect mostly everbody (except brand-new newcomers) to be aware of interior mutability. What I don't expect is for people _immediately_ see that it's being used in Completion, and connect the dots from there. Keyword here being "immediately", users will naturally realize this in a couple of minutes at max, of course. Anyways, I guess we can use Completion then. TBH I wasn't aware of the UB thing, so I can see how you also have a point. On top of that, we can use the words "interior mutability" somewhere in the example as well to make it even clearer. I'll change it for v8. -- Daniel