|
|
Log in / Subscribe / Register

Abuses of mutable references

Abuses of mutable references

Posted Oct 2, 2024 13:44 UTC (Wed) by farnz (subscriber, #17727)
In reply to: Locking by excors
Parent article: Resources for learning Rust for kernel development

Note when doing that sort of analysis that you also have to take into account std::mem::swap and friends. An exclusive reference to a type I cannot construct works fine for what you describe, but once you allow a user-chosen type into the closure parameters, you have to consider what happens if I swap it out for another one I have lying around. I think that for the case of a single layer of locking, it's fine, but it becomes more exciting once you consider the case of nested locks, and my brain isn't up to looking for obscure corner cases in that situation.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds