@@ -164,15 +164,13 @@ impl Layout {
164164 /// alignment. In other words, if `K` has size 16, `K.align_to(32)`
165165 /// will *still* have size 16.
166166 ///
167- /// # Panics
168- ///
169- /// Panics if the combination of `self.size()` and the given `align`
170- /// violates the conditions listed in
167+ /// Returns an error if the combination of `self.size()` and the given
168+ /// `align` violates the conditions listed in
171169 /// [`Layout::from_size_align`](#method.from_size_align).
172170 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
173171 #[ inline]
174- pub fn align_to ( & self , align : usize ) -> Self {
175- Layout :: from_size_align ( self . size ( ) , cmp:: max ( self . align ( ) , align) ) . unwrap ( )
172+ pub fn align_to ( & self , align : usize ) -> Result < Self , LayoutErr > {
173+ Layout :: from_size_align ( self . size ( ) , cmp:: max ( self . align ( ) , align) )
176174 }
177175
178176 /// Returns the amount of padding we must insert after `self`
@@ -296,23 +294,14 @@ impl Layout {
296294 /// padding is inserted, the alignment of `next` is irrelevant,
297295 /// and is not incorporated *at all* into the resulting layout.
298296 ///
299- /// Returns `(k, offset)`, where `k` is layout of the concatenated
300- /// record and `offset` is the relative location, in bytes, of the
301- /// start of the `next` embedded within the concatenated record
302- /// (assuming that the record itself starts at offset 0).
303- ///
304- /// (The `offset` is always the same as `self.size()`; we use this
305- /// signature out of convenience in matching the signature of
306- /// `extend`.)
307- ///
308297 /// On arithmetic overflow, returns `LayoutErr`.
309298 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
310299 #[ inline]
311- pub fn extend_packed ( & self , next : Self ) -> Result < ( Self , usize ) , LayoutErr > {
300+ pub fn extend_packed ( & self , next : Self ) -> Result < Self , LayoutErr > {
312301 let new_size = self . size ( ) . checked_add ( next. size ( ) )
313302 . ok_or ( LayoutErr { private : ( ) } ) ?;
314303 let layout = Layout :: from_size_align ( new_size, self . align ( ) ) ?;
315- Ok ( ( layout, self . size ( ) ) )
304+ Ok ( layout)
316305 }
317306
318307 /// Creates a layout describing the record for a `[T; n]`.
0 commit comments