Skip to content

Commit 574bca7

Browse files
committed
Cleanup Deref impls and add ?Sized bound to &mut T impls
1 parent 403d12d commit 574bca7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libcore/pin.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<P: Deref> Pin<P> {
154154
#[unstable(feature = "pin", issue = "49150")]
155155
#[inline(always)]
156156
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> {
157-
unsafe { Pin::new_unchecked(&**self) }
157+
unsafe { Pin::new_unchecked(&*self.pointer) }
158158
}
159159
}
160160

@@ -212,7 +212,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
212212
}
213213
}
214214

215-
impl<'a, T> Pin<&'a mut T> {
215+
impl<'a, T: ?Sized> Pin<&'a mut T> {
216216
/// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
217217
#[unstable(feature = "pin", issue = "49150")]
218218
#[inline(always)]
@@ -278,7 +278,7 @@ impl<'a, T> Pin<&'a mut T> {
278278
impl<P: Deref> Deref for Pin<P> {
279279
type Target = P::Target;
280280
fn deref(&self) -> &P::Target {
281-
&*self.pointer
281+
Pin::get_ref(Pin::as_ref(self))
282282
}
283283
}
284284

@@ -288,7 +288,7 @@ where
288288
P::Target: Unpin
289289
{
290290
fn deref_mut(&mut self) -> &mut P::Target {
291-
&mut *self.pointer
291+
Pin::get_mut(Pin::as_mut(self))
292292
}
293293
}
294294

0 commit comments

Comments
 (0)