diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2017-07-26 06:15:01 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-26 06:15:01 -0600 |
| commit | b5b7266b786cb953581ba588d400bddcdae4a852 (patch) | |
| tree | c957402d4bf9f3f60cc718e86bf45ebba616bf4b /src/libstd | |
| parent | bad58f27916e7e233cc2916dcc9167708077e792 (diff) | |
| parent | 0d1864b8cf9585e6133aa3da2b06b29cbfb791bd (diff) | |
| download | rust-b5b7266b786cb953581ba588d400bddcdae4a852.tar.gz rust-b5b7266b786cb953581ba588d400bddcdae4a852.zip | |
Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfackler
Make the "main" constructors of NonZero/Shared/Unique return Option Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441. This is a breaking change to unstable APIs. The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts. In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 06f4f7643ec..3844690860b 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -44,7 +44,7 @@ impl TaggedHashUintPtr { #[inline] unsafe fn new(ptr: *mut HashUint) -> Self { debug_assert!(ptr as usize & 1 == 0 || ptr as usize == EMPTY as usize); - TaggedHashUintPtr(Unique::new(ptr)) + TaggedHashUintPtr(Unique::new_unchecked(ptr)) } #[inline] @@ -56,7 +56,7 @@ impl TaggedHashUintPtr { } else { usize_ptr &= !1; } - self.0 = Unique::new(usize_ptr as *mut HashUint) + self.0 = Unique::new_unchecked(usize_ptr as *mut HashUint) } } @@ -877,7 +877,7 @@ impl<K, V> RawTable<K, V> { elems_left: elems_left, marker: marker::PhantomData, }, - table: unsafe { Shared::new(self) }, + table: Shared::from(self), marker: marker::PhantomData, } } |
