File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -952,8 +952,9 @@ impl<T: ?Sized> Rc<T> {
952952 #[ inline]
953953 #[ unstable( feature = "rc_as_weak" , issue = "100472" ) ]
954954 #[ must_use]
955- pub const fn as_weak < ' a > ( this : & ' a Self ) -> & ' a Weak < T > {
956- unsafe { mem:: transmute :: < & ' a Rc < T > , & ' a Weak < T > > ( this) }
955+ pub const fn as_weak ( this : & Self ) -> & Weak < T > {
956+ let weak = this as * const Self as * const Weak < T > ;
957+ unsafe { & * weak }
957958 }
958959
959960 /// Gets the number of [`Weak`] pointers to this allocation.
Original file line number Diff line number Diff line change @@ -979,8 +979,9 @@ impl<T: ?Sized> Arc<T> {
979979 #[ inline]
980980 #[ unstable( feature = "rc_as_weak" , issue = "100472" ) ]
981981 #[ must_use]
982- pub const fn as_weak < ' a > ( this : & ' a Self ) -> & ' a Weak < T > {
983- unsafe { mem:: transmute :: < & ' a Arc < T > , & ' a Weak < T > > ( this) }
982+ pub const fn as_weak ( this : & Self ) -> & Weak < T > {
983+ let weak = this as * const Self as * const Weak < T > ;
984+ unsafe { & * weak }
984985 }
985986
986987 /// Gets the number of [`Weak`] pointers to this allocation.
You can’t perform that action at this time.
0 commit comments