this post was submitted on 08 Oct 2025
18 points (100.0% liked)

Rust

7572 readers
4 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
top 5 comments
sorted by: hot top controversial new old
[–] INeedMana@piefed.zip 0 points 2 months ago (1 children)

Why not just expand meaning of &?

let l_before = &v1;

[–] SorteKanin@feddit.dk 5 points 2 months ago (1 children)

How do I now actually get a &Arc? Without implicitly cloning?

& is such a fundamental part of the syntax, I really don't think it's meaning should be muddled.

[–] INeedMana@piefed.zip 1 points 2 months ago (1 children)

What's the use-case for &Arc? Modifying an Arc object in outer scope?

To me, this handle trait sounds a lot like "reference-counted reference". When there already exists a pure "reference" in the language

[–] SorteKanin@feddit.dk 1 points 2 months ago (1 children)

I don't know but it could be anything else than an Arc. Obviously you should still be able to take a usual reference to such a thing.

References are just pointers, they don't have any counting. This proposal as I understand it is an attempt at making reference-counting more ergonomic.

[–] INeedMana@piefed.zip 2 points 2 months ago

I don’t know but it could be anything else than an Arc. Obviously you should still be able to take a usual reference to such a thing.

Maybe. My point is that unless you want to, for example, have a reference that you switch between which object it references, I think you would be fine with using the ref-counted reference. With eventual optimization done via compiler when it's sure the code won't be trying to access the object after it got deleted. But even if I'm wrong, there could be another way to get a pure reference

This proposal as I understand it is an attempt at making reference-counting more ergonomic.

Yes, and IMO by using Handle for that it breaks a pattern. Rust keeps * and & for speaking about values and memory management (I want data vs I want reference). Using a trait for ref-counted referencing adds another layer. So suddenly we have *, & and ::Handle(). You see what I'm getting at?