@@ -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).
172- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
170+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
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`
@@ -191,7 +189,7 @@ impl Layout {
191189 /// to be less than or equal to the alignment of the starting
192190 /// address for the whole allocated block of memory. One way to
193191 /// satisfy this constraint is to ensure `align <= self.align()`.
194- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
192+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
195193 #[ inline]
196194 pub fn padding_needed_for ( & self , align : usize ) -> usize {
197195 let len = self . size ( ) ;
@@ -228,7 +226,7 @@ impl Layout {
228226 /// of each element in the array.
229227 ///
230228 /// On arithmetic overflow, returns `LayoutErr`.
231- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
229+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
232230 #[ inline]
233231 pub fn repeat ( & self , n : usize ) -> Result < ( Self , usize ) , LayoutErr > {
234232 let padded_size = self . size ( ) . checked_add ( self . padding_needed_for ( self . align ( ) ) )
@@ -248,13 +246,16 @@ impl Layout {
248246 /// will be properly aligned. Note that the result layout will
249247 /// satisfy the alignment properties of both `self` and `next`.
250248 ///
249+ /// The resulting layout will be the same as that of a C struct containing
250+ /// two fields with the layouts of `self` and `next`, in that order.
251+ ///
251252 /// Returns `Some((k, offset))`, where `k` is layout of the concatenated
252253 /// record and `offset` is the relative location, in bytes, of the
253254 /// start of the `next` embedded within the concatenated record
254255 /// (assuming that the record itself starts at offset 0).
255256 ///
256257 /// On arithmetic overflow, returns `LayoutErr`.
257- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
258+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
258259 #[ inline]
259260 pub fn extend ( & self , next : Self ) -> Result < ( Self , usize ) , LayoutErr > {
260261 let new_align = cmp:: max ( self . align ( ) , next. align ( ) ) ;
@@ -281,7 +282,7 @@ impl Layout {
281282 /// aligned.
282283 ///
283284 /// On arithmetic overflow, returns `LayoutErr`.
284- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
285+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
285286 #[ inline]
286287 pub fn repeat_packed ( & self , n : usize ) -> Result < Self , LayoutErr > {
287288 let size = self . size ( ) . checked_mul ( n) . ok_or ( LayoutErr { private : ( ) } ) ?;
@@ -293,29 +294,20 @@ impl Layout {
293294 /// padding is inserted, the alignment of `next` is irrelevant,
294295 /// and is not incorporated *at all* into the resulting layout.
295296 ///
296- /// Returns `(k, offset)`, where `k` is layout of the concatenated
297- /// record and `offset` is the relative location, in bytes, of the
298- /// start of the `next` embedded within the concatenated record
299- /// (assuming that the record itself starts at offset 0).
300- ///
301- /// (The `offset` is always the same as `self.size()`; we use this
302- /// signature out of convenience in matching the signature of
303- /// `extend`.)
304- ///
305297 /// On arithmetic overflow, returns `LayoutErr`.
306- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
298+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
307299 #[ inline]
308- pub fn extend_packed ( & self , next : Self ) -> Result < ( Self , usize ) , LayoutErr > {
300+ pub fn extend_packed ( & self , next : Self ) -> Result < Self , LayoutErr > {
309301 let new_size = self . size ( ) . checked_add ( next. size ( ) )
310302 . ok_or ( LayoutErr { private : ( ) } ) ?;
311303 let layout = Layout :: from_size_align ( new_size, self . align ( ) ) ?;
312- Ok ( ( layout, self . size ( ) ) )
304+ Ok ( layout)
313305 }
314306
315307 /// Creates a layout describing the record for a `[T; n]`.
316308 ///
317309 /// On arithmetic overflow, returns `LayoutErr`.
318- #[ unstable( feature = "allocator_api " , issue = "32838 " ) ]
310+ #[ unstable( feature = "alloc_layout_extra " , issue = "55724 " ) ]
319311 #[ inline]
320312 pub fn array < T > ( n : usize ) -> Result < Self , LayoutErr > {
321313 Layout :: new :: < T > ( )
0 commit comments