@@ -164,15 +164,13 @@ impl Layout {
164
164
/// alignment. In other words, if `K` has size 16, `K.align_to(32)`
165
165
/// will *still* have size 16.
166
166
///
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
171
169
/// [`Layout::from_size_align`](#method.from_size_align).
172
170
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
173
171
#[ 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) )
176
174
}
177
175
178
176
/// Returns the amount of padding we must insert after `self`
@@ -296,23 +294,14 @@ impl Layout {
296
294
/// padding is inserted, the alignment of `next` is irrelevant,
297
295
/// and is not incorporated *at all* into the resulting layout.
298
296
///
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
- ///
308
297
/// On arithmetic overflow, returns `LayoutErr`.
309
298
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
310
299
#[ inline]
311
- pub fn extend_packed ( & self , next : Self ) -> Result < ( Self , usize ) , LayoutErr > {
300
+ pub fn extend_packed ( & self , next : Self ) -> Result < Self , LayoutErr > {
312
301
let new_size = self . size ( ) . checked_add ( next. size ( ) )
313
302
. ok_or ( LayoutErr { private : ( ) } ) ?;
314
303
let layout = Layout :: from_size_align ( new_size, self . align ( ) ) ?;
315
- Ok ( ( layout, self . size ( ) ) )
304
+ Ok ( layout)
316
305
}
317
306
318
307
/// Creates a layout describing the record for a `[T; n]`.
0 commit comments