Skip to content
Rust Search
← RustWeek 2026

Can I borrow that? (Reborrow traits)

RustNL
RustWeek 19:54 1017 views

Can I borrow that? (Reborrow traits) by Aapo Alasuutari. Exclusive references make Rust, yet they cannot be built within Rust: the core act of reborrowing, that is giving temporary exclusive access and reclaiming exclusivity afterwards, is a feature implemented outside of the language. For custom user types or even reference wrappers like `Option &mut T` the best one can do is use explicit methods like `as_deref_mut` or `rb_mut`. The `Reborrow` traits project goal aims to fix this gap and make

Player unavailable or embedding blocked? Use the YouTube link above.

Other talks by Aapo Alasuutari

Abusing reborrowing for fun, profit, and a safepoint garbage collector

FOSDEM

Rust's references adhere to a strict "one exclusive XOR many shared" model, which gives the language much of its greatest safety guarantees. Reborrowing is a feature that seems on surface to break this rule: An exclusive reference can be turned into shared references and those shared references can be used together with the exclusive reference as long as these are all used as if they were shared references. Only once the exclusive reference is used as exclusive, all the derived or "reborrowed" shared references are invalidated. The XOR rule is upheld, but in a way that breaks a literal reading of the rule. Usually reborrowing is used temporarily but what if we make it our modus operandi? This talk explores using and slightly abusing reborrowing and comes out the other side with an awkward but functional safepoint garbage collector built upon reborrowing a ZST marker and a whole load of typed indexes. The garbage collector is part of the Nova JavaScript engine. https://trynova.dev/