Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `NonZero`/`Unique`/`Shared` stabilization #27730
Comments
aturon
added
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
I'm not a fan of NonZero. I would like a more robust system that can hook into the things described in rust-lang/rfcs#1230. Unique is great, but I would like to rename it to Owned to better reflect what its actual semantics are (e.g. it's fine to have other pointers into it just like it's fine for Box). I would like to add a Shared equivalent for Rc/Arc to use. This is blocked by #26905 |
Ms2ger
referenced this issue
Aug 16, 2015
Open
Tracking: Unstable Rust feature gates used by Servo #5286
huonw
changed the title
Tracking issue for `NonZero`/`Unique` stabilization
Tracking issue for `NonZero`/`Unique`/`Shared` stabilization
Oct 20, 2015
This comment has been minimized.
This comment has been minimized.
|
I expanded this issue to cover the new |
huonw
added a commit
to huonw/rust
that referenced
this issue
Oct 20, 2015
This comment has been minimized.
This comment has been minimized.
|
CC @SimonSapin Does Shared/Unique cover all your NonZero usecases? |
This comment has been minimized.
This comment has been minimized.
|
I commented about this in #29110, reposting here for visibility: The They also allow writing
|
SSheldon
referenced this issue
Nov 7, 2015
Open
Allow Option<Id<T>> to use the null pointer optimization #2
This comment has been minimized.
This comment has been minimized.
|
@eddyb alternatively, we could just promote these types to compiler primitives, right? Have them coerce to raw pointers or summat? This may also improve debug perf, as there's less abstraction in the way if it's really "just" a raw pointer, and not a Foo(Bar(*const T)) that is accessed through two levels of methods. |
pnkfelix
referenced this issue
Jan 26, 2016
Closed
NonZero constructor in debug-builds should assert input is actually nonzero. #31217
This comment has been minimized.
This comment has been minimized.
|
I agree with @eddyb's comment about using a |
alexcrichton
added
the
I-nominated
label
Apr 19, 2016
This comment has been minimized.
This comment has been minimized.
|
The libs team decided to not move these APIs into FCP this cycle because the |
alexcrichton
removed
the
I-nominated
label
Apr 29, 2016
This comment has been minimized.
This comment has been minimized.
(Answering with a small delay… :)) Unfortunately no. We would like to use |
This comment has been minimized.
This comment has been minimized.
rbtcollins
commented
Jun 1, 2016
|
I don't know if this is the right place to comment, but I'm binding some C code and Unique appears perfect - except that it exposes the unsafe rather than that being internal - meaning that I need a further wrapper around it - since I know the C ptr in question isn't going to be freed randomly, and I know that its not null, I want to hide the unsafe entirely from further out users. |
This comment has been minimized.
This comment has been minimized.
|
@rbtcollins My suggestion would be to write a wrapper struct that has a |
This comment has been minimized.
This comment has been minimized.
|
N.B. |
This comment has been minimized.
This comment has been minimized.
|
If we keep NonZero or something like it, I would love a safe (checked) way to construct one. Currently the single line of unsafe code in Serde is constructing a NonZero. if value == Zero::zero() {
return Err(Error::invalid_value("expected a non-zero value"))
}
unsafe {
Ok(NonZero::new(value))
} |
This comment has been minimized.
This comment has been minimized.
|
I'm making changes to this API in this PR #41064 |
This comment has been minimized.
This comment has been minimized.
HyeonuPark
commented
Jan 6, 2018
|
Ah yeah that's the point, I think As I understand,
Does this code makes sense? |
This comment has been minimized.
This comment has been minimized.
|
We should maybe abuse trait privacy (if we can, at all) to make it impossible to implement the trait outside of |
This comment has been minimized.
This comment has been minimized.
|
I was hoping to land #46952 and get |
This comment has been minimized.
This comment has been minimized.
|
Assuming you mean via a hidden private |
This comment has been minimized.
This comment has been minimized.
|
Right, I meant "remove" as far as the public API is concerned. We can have a private generic type (with or without a trait bound) in the implementation, or whatever’s easier to maintain for the compiler. |
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jan 17, 2018
bors
added a commit
that referenced
this issue
Jan 20, 2018
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Jan 20, 2018
bors
added a commit
that referenced
this issue
Jan 20, 2018
SimonSapin
referenced this issue
Jan 21, 2018
Merged
Add some APIs to ptr::NonNull and fix `since` attributes #47631
This comment has been minimized.
This comment has been minimized.
|
Shared is now renamed NonNull and stable; Unique is a permanently-unstable internal implementation detail of std: #47631 This only leaves NonZero for this tracking issue, which is now mostly only useful for integers. I just published rust-lang/rfcs#2307 which propose adding 12 concrete types like |
This comment has been minimized.
This comment has been minimized.
|
Also some NonNull follow up: #47631 |
cuviper
pushed a commit
to cuviper/rayon-hash
that referenced
this issue
Jan 22, 2018
bstrie
referenced this issue
Jan 24, 2018
Merged
RFC: Add std::num::NonZeroU32 and friends, deprecate core::nonzero #2307
bors
added a commit
that referenced
this issue
Feb 7, 2018
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Feb 7, 2018
This comment has been minimized.
This comment has been minimized.
Implementation PR, ready to merge: #48265
After whatever time is appropriate for the deprecation period of unstable features, we can land SimonSapin#1 to make |
SimonSapin
referenced this issue
Feb 16, 2018
Merged
Add 12 num::NonZero* types for primitive integers, deprecate core::nonzero #48265
This comment has been minimized.
This comment has been minimized.
|
Hm, this probably way too late, but are we sure that the name should be Would just a EDIT: nvm, see that this already was discussed in another issue: #46952 (comment) |
This comment has been minimized.
This comment has been minimized.
|
The enum optimization is my motivation for pushing this feature to stabilization, FWIW. I think you could already get covariance before by using |
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Mar 18, 2018
bors
added a commit
that referenced
this issue
Mar 21, 2018
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
Mar 23, 2018
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Mar 23, 2018
alexcrichton
closed this
in
#48265
Mar 23, 2018
This comment has been minimized.
This comment has been minimized.
|
Tracking issue for the new |
aturon commentedAug 12, 2015
We currently have three internal types,
NonZero,UniqueandShared, that are very useful when working with unsafe Rust code. Ultimately, the hope is to have a clear vision for semi-high-level, but unsafe programming using types like these.None of the current APIs have gone through the RFC process, and a comprehensive RFC should be written before any stabilization is done.
cc @Gankro