Skip to content
Myr

Force turbofish on all calls of .cast::<U>()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 8b19147 · Browse files · 1 file+12 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−3 removed

  • other:+12 added−3 removed

1 file+12 added−3 removed

modified:src/ptr.rs+12 added-3 removed
21 unmodified lines
22 ptr: unsafe { NonNull::new_unchecked(Box::into_raw(ptr)) },23 }24 }2526 pub fn cast<U>(self) -> Own<U> {26 pub fn cast<U: CastTo>(self) -> Own<U::Target> {27 Own {28 ptr: self.ptr.cast(),29 }30 }
37 unmodified lines
68 lifetime: PhantomData,69 }70 }7172 pub fn cast<U>(self) -> Ref<'a, U> {72 pub fn cast<U: CastTo>(self) -> Ref<'a, U::Target> {73 Ref {74 ptr: self.ptr.cast(),75 lifetime: PhantomData,76 }
24 unmodified lines
101 lifetime: PhantomData,102 }103 }104105 pub fn cast<U>(self) -> Mut<'a, U> {105 pub fn cast<U: CastTo>(self) -> Mut<'a, U::Target> {106 Mut {107 ptr: self.ptr.cast(),108 lifetime: PhantomData,109 }
13 unmodified lines
123 pub unsafe fn read(self) -> T {124 self.ptr.as_ptr().read()125 }126}127128// Force turbofish on all calls of `.cast::<U>()`.129pub trait CastTo {130 type Target;131}132133impl<T> CastTo for T {134 type Target = T;135}