Clippy actually warns by default if you use `foo.clone()` instead of `Rc::clone`. IMO using `clone` instead of `retain` or something explicit was a mistake
-
-
-
Replying to @mountain_ghosts @sgrif
when copying around reference counted pointers, especially in C++, operations can be either "adopt" or "retain", "adopt" means you're "adopting" the object and don't change the refcount (this is a move in Rust)
1 reply 0 retweets 1 like -
"retain" means you're creating a new ref and the old one should "retain" its refcount, so you increment the refcount. C++ refcount libs often interface with raw ptrs (and often use intrusive refcounting) so this terminology is more common, but it sometimes crops up for rust
1 reply 0 retweets 1 like -
Replying to @ManishEarth @mountain_ghosts
I know it from pre-arc objective C which is the only other time I've ever worked with explicit reference counting
1 reply 0 retweets 2 likes -
I just sorta assumed it was standard terminology
1 reply 0 retweets 2 likes -
Replying to @sgrif @mountain_ghosts
it is! it's just not as used in rust because moves handle adoption (so retain is the only thing that happens explicitly) and only time you need to worry about "adopt" is when you're interfacing with raw pointers (rare)https://github.com/retep998/wio-rs/issues/20 …
1 reply 0 retweets 1 like -
Replying to @ManishEarth @mountain_ghosts
My main point was just that `clone` implies it's doing a lot more than it really is (even if incrementing the ref count is technically correct impl of clone for Rc). The fact that we push everyone to use `Rc::clone` for explicitness says that `clone` was the wrong term to me
1 reply 0 retweets 1 like -
Replying to @sgrif @mountain_ghosts
oh, definitely, i'm not disagreeing with you :) I think the only reason Rc uses clone() is because then it interfaces very nicely with derive(Clone)
2 replies 0 retweets 1 like -
i mostly wanted to give broader context on retain/adopt since it's a useful terminology distinction, but lots of folks aren't familiar with it
1 reply 0 retweets 1 like
Yeah, I hadn't heard `adopt` before. That makes a lot of sense
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.