What is Allocator::by_ref for?
Rust Internals [Unofficial]
May 25, 2026
Iterator::by_ref is useful because many of the methods take self, especially when creating new adaptors, but there is also the blanket impl on &mut I so you can have those capture a reference instead via iter.by_ref().foo() -- or equally (&mut iter).foo(). io::Read::by_ref is similar since there are self methods for adaptors.
io::Write and Allocator also have similar blanket impls, but they don't have any self-consuming methods AFAICS, so I don't know why we should want by_ref(). I only found two existing uses of Allocator::by_ref in Arc/Rc::from_box_in, and both would be more succinct to use &alloc.
Discussion in the ATmosphere