{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreid4v2huhnwch6ywtkv7ga4kvnng6qk7hgj3qtrzwqjubczfhk3wsq",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmp65yelwxb2"
},
"path": "/t/what-is-allocator-by-ref-for/24356#post_7",
"publishedAt": "2026-05-25T17:37:12.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"Add a \"by reference\" adaptor for `AllocRef` by TimDiekmann · Pull Request #71442 · rust-lang/rust · GitHub",
"The issue mentions"
],
"textContent": "That’s not a good reason to have it for `Allocator`, though. I can see that someone might want to pass `&MyAllocator` when constructing a container, but that will never be a method chain.\n\nAccording to the revision history, `by_ref` was added in Add a \"by reference\" adaptor for `AllocRef` by TimDiekmann · Pull Request #71442 · rust-lang/rust · GitHub, which was primarily about adding the `&A` (at the time, `&mut A`) implementation. The issue mentions adding `by_ref` by analogy with `io::Write::by_ref()`. Which seems to me to be a method with equally little reason to exist, but perhaps I am missing something.",
"title": "What is Allocator::by_ref for?"
}