File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -2176,18 +2176,19 @@ impl<T: ?Sized> AsRef<T> for Rc<T> {
21762176impl < T : ?Sized > Unpin for Rc < T > { }
21772177
21782178unsafe fn data_offset < T : ?Sized > ( ptr : * const T ) -> isize {
2179- // Align the unsized value to the end of the RcBox.
2179+ // Align the unsized value to the end of the ` RcBox` .
21802180 // Because it is ?Sized, it will always be the last field in memory.
2181- let align = align_of_val ( & * ptr) ;
2182- let layout = Layout :: new :: < RcBox < ( ) > > ( ) ;
2183- ( layout. size ( ) + layout. padding_needed_for ( align) ) as isize
2181+ data_offset_align ( align_of_val ( & * ptr) )
21842182}
21852183
2186- /// Computes the offset of the data field within ArcInner .
2184+ /// Computes the offset of the data field within `RcBox` .
21872185///
21882186/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`.
21892187fn data_offset_sized < T > ( ) -> isize {
2190- let align = align_of :: < T > ( ) ;
2188+ data_offset_align ( align_of :: < T > ( ) )
2189+ }
2190+
2191+ fn data_offset_align ( align : usize ) -> isize {
21912192 let layout = Layout :: new :: < RcBox < ( ) > > ( ) ;
21922193 ( layout. size ( ) + layout. padding_needed_for ( align) ) as isize
21932194}
You can’t perform that action at this time.
0 commit comments