Uh oh!
There was an error while loading. Please reload this page.
Added Arc::try_unique - #23844
Conversation
rust-highfive
commented
Mar 29, 2015
(rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Mar 30, 2015
Thanks for the PR! In the past we've generally been pretty hesitant about adding inherent methods on smart pointers, however as they will shadow all other methods of the same name. In the past we've requested that extra functionality for smart pointers go as top-level functions as well. Also, we do seem to definitely have a bit of a sprawling story for extra functionality on smart pointers, there's an interesting subset of functionality between cc @aturon, do you have thoughts on adding apis such as this? |
kvark
commented
Mar 30, 2015
@alexcrichton thanks for the info! May I wonder why top-level functions are preferred for smart pointers instead of the member functions? I'd be happy to use the existing functions without introducing more, but as I said there is no way to get the mutable contents at the moment without As for the intersection, for gfx-rs we'll need some sort of abstraction over |
alexcrichton
commented
Mar 30, 2015
Right now if a smart pointer let ptr:P<T> = ...;ptr.foo();This is because the receiver's methods trump the |
kvark
commented
Mar 30, 2015
Oh, thanks, I get this now! |
alexcrichton
commented
Mar 30, 2015
You can indeed! I also forgot, but you can also do |
kvark
commented
Mar 31, 2015
Just to clarify - are we waiting for me to change the methods to be global, or are we blocked by @aturon to look into it? |
aturon
commented
Mar 31, 2015
@kvark Sorry for the delay. I'm happy to add a top-level experimental APIs like this. I'd like to suggest a single method |
kvark
commented
Mar 31, 2015
@aturon Right, I only added I'll update the PR shortly. Thanks for having a look! |
kvark
commented
Apr 1, 2015
Done. Anything else I need to fix? |
alexcrichton
commented
Apr 1, 2015
While trying to implement parallel ECS processing, I stumbled upon the need to mutate `Arc` contents. The only existed method that allowed that was `make_unique`, but it has issues: - it may clone the data as if nothing happened, where the program may just need to crash - it forces `Clone` bound, which I don't have The new `try_unique` allows accessing the contents mutably without `Clone` bound and error out if the pointer is not unique.
bors
commented
Apr 1, 2015
⌛ Testing commit 39aa668 with merge 6a7d49e... |
bors
commented
Apr 1, 2015
💔 Test failed - auto-mac-32-opt |
kvark
commented
Apr 2, 2015
@alexcrichton but.. bors showed that my docs were incorrect. Are you sure about merging? |
alexcrichton
commented
Apr 2, 2015
No worries! I fixed them in the rollup |
kvark
commented
Apr 2, 2015
@alexcrichton thanks! My machine takes ages to build and check everything... |
lilyball
commented
Apr 3, 2015
Is there some reason this was named |
kvark
commented
Apr 3, 2015
@kballard no, I wasn't aware of |
lilyball
commented
Apr 3, 2015
There's a lot of precedent in the collection types (including slices) for a |
kvark
commented
Apr 3, 2015
@kballard I'll make a PR tonight to change it. |
lilyball
commented
Apr 3, 2015
Awesome, thanks. That's one less thing for me to try and remember (since I'm on vacation right now 😀) |
While trying to implement parallel ECS processing, I stumbled upon the need to mutate
Arccontents. The only existed method that allowed that wasmake_unique, but it has issues:Clonebound, which I don't haveThe new
try_uniqueallows accessing the contents mutably withoutClonebound and error out if the pointer is not unique.