diff options
| author | bors <bors@rust-lang.org> | 2018-06-26 11:20:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-26 11:20:18 +0000 |
| commit | 764232cb2a8407c72b9fea68835e686240e30ef3 (patch) | |
| tree | d97ad05cf89b5e952cd58394ea8c5e8b4e82c803 /src/libcore | |
| parent | 309fd8a6fb059d38ea56274968feff2ef738184b (diff) | |
| parent | a539885450313a6cfd50312ec12a4a84d546d87c (diff) | |
| download | rust-764232cb2a8407c72b9fea68835e686240e30ef3.tar.gz rust-764232cb2a8407c72b9fea68835e686240e30ef3.zip | |
Auto merge of #51805 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests Successful merges: - #51104 (add `dyn ` to display of dynamic (trait) types) - #51153 (Link panic and compile_error docs) - #51642 (Fix unknown windows build) - #51730 (New safe associated functions for PinMut) - #51731 (Fix ICEs when using continue as an array length inside closures (inside loop conditions)) - #51747 (Add error for using null characters in #[export_name]) - #51769 (Update broken rustc-guide links) - #51786 (Remove unnecessary stat64 pointer casts) - #51788 (Fix typo) - #51789 (Don't ICE when performing `lower_pattern_unadjusted` on a `TyError`) - #51791 (Minify css) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/mem.rs | 14 | ||||
| -rw-r--r-- | src/libcore/option.rs | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 31635ffa53c..08bd9289ab4 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1119,6 +1119,12 @@ impl<'a, T: ?Sized + Unpin> PinMut<'a, T> { pub fn new(reference: &'a mut T) -> PinMut<'a, T> { PinMut { inner: reference } } + + /// Get a mutable reference to the data inside of this `PinMut`. + #[unstable(feature = "pin", issue = "49150")] + pub fn get_mut(this: PinMut<'a, T>) -> &'a mut T { + this.inner + } } @@ -1150,21 +1156,21 @@ impl<'a, T: ?Sized> PinMut<'a, T> { /// the data out of the mutable reference you receive when you call this /// function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn get_mut(this: PinMut<'a, T>) -> &'a mut T { + pub unsafe fn get_mut_unchecked(this: PinMut<'a, T>) -> &'a mut T { this.inner } /// Construct a new pin by mapping the interior value. /// - /// For example, if you wanted to get a `PinMut` of a field of something, you - /// could use this to get access to that field in one line of code. + /// For example, if you wanted to get a `PinMut` of a field of something, + /// you could use this to get access to that field in one line of code. /// /// This function is unsafe. You must guarantee that the data you return /// will not move so long as the argument value does not move (for example, /// because it is one of the fields of that value), and also that you do /// not move out of the argument you receive to the interior function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn map<U, F>(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where + pub unsafe fn map_unchecked<U, F>(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where F: FnOnce(&mut T) -> &mut U { PinMut { inner: f(this.inner) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index e633d80a63c..20bc173f7e1 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -275,7 +275,7 @@ impl<T> Option<T> { #[unstable(feature = "pin", issue = "49150")] pub fn as_pin_mut<'a>(self: PinMut<'a, Self>) -> Option<PinMut<'a, T>> { unsafe { - PinMut::get_mut(self).as_mut().map(|x| PinMut::new_unchecked(x)) + PinMut::get_mut_unchecked(self).as_mut().map(|x| PinMut::new_unchecked(x)) } } |
