diff options
| author | bors <bors@rust-lang.org> | 2016-02-07 07:57:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-07 07:57:06 +0000 |
| commit | e548d6c08f87c6a0a15a91c21df0990112b5a7f4 (patch) | |
| tree | b7854eab01ce4ac0625cb67dd1f2397a9636c4e0 | |
| parent | 1678072ce8f3f28f27dee49f51f7edea824944bd (diff) | |
| parent | 70650f849f7b88105c13f928308dd959d45e7af5 (diff) | |
| download | rust-e548d6c08f87c6a0a15a91c21df0990112b5a7f4.tar.gz rust-e548d6c08f87c6a0a15a91c21df0990112b5a7f4.zip | |
Auto merge of #31450 - bluss:no-null-markers, r=Gankro
Document that Unique<T> and Shared<T> are non-null
| -rw-r--r-- | src/libcore/ptr.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index e1e7869d548..a826f2bb444 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -465,7 +465,7 @@ impl<T: ?Sized> PartialOrd for *mut T { fn ge(&self, other: &*mut T) -> bool { *self >= *other } } -/// A wrapper around a raw `*mut T` that indicates that the possessor +/// A wrapper around a raw non-null `*mut T` that indicates that the possessor /// of this wrapper owns the referent. This in turn implies that the /// `Unique<T>` is `Send`/`Sync` if `T` is `Send`/`Sync`, unlike a raw /// `*mut T` (which conveys no particular ownership semantics). It @@ -502,6 +502,10 @@ unsafe impl<T: Sync + ?Sized> Sync for Unique<T> { } #[unstable(feature = "unique", issue = "27730")] impl<T: ?Sized> Unique<T> { /// Creates a new `Unique`. + /// + /// # Safety + /// + /// `ptr` must be non-null. pub const unsafe fn new(ptr: *mut T) -> Unique<T> { Unique { pointer: NonZero::new(ptr), _marker: PhantomData } } @@ -537,7 +541,7 @@ impl<T> fmt::Pointer for Unique<T> { } } -/// A wrapper around a raw `*mut T` that indicates that the possessor +/// A wrapper around a raw non-null `*mut T` that indicates that the possessor /// of this wrapper has shared ownership of the referent. Useful for /// building abstractions like `Rc<T>` or `Arc<T>`, which internally /// use raw pointers to manage the memory that they own. @@ -566,6 +570,10 @@ impl<T: ?Sized> !Sync for Shared<T> { } #[unstable(feature = "shared", issue = "27730")] impl<T: ?Sized> Shared<T> { /// Creates a new `Shared`. + /// + /// # Safety + /// + /// `ptr` must be non-null. pub unsafe fn new(ptr: *mut T) -> Self { Shared { pointer: NonZero::new(ptr), _marker: PhantomData } } |
