@@ -45,7 +45,7 @@ fn size_align<T>() -> (usize, usize) {
45
45
/// requests have positive size. A caller to the `Alloc::alloc`
46
46
/// method must either ensure that conditions like this are met, or
47
47
/// use specific allocators with looser requirements.)
48
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
48
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
49
49
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
50
50
pub struct Layout {
51
51
// size of the requested block of memory, measured in bytes.
@@ -76,7 +76,7 @@ impl Layout {
76
76
/// * `size`, when rounded up to the nearest multiple of `align`,
77
77
/// must not overflow (i.e. the rounded value must be less than
78
78
/// `usize::MAX`).
79
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
79
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
80
80
#[ inline]
81
81
pub fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutErr > {
82
82
if !align. is_power_of_two ( ) {
@@ -113,24 +113,25 @@ impl Layout {
113
113
/// This function is unsafe as it does not verify that `align` is
114
114
/// a power-of-two nor `size` aligned to `align` fits within the
115
115
/// address space (i.e. the `Layout::from_size_align` preconditions).
116
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
116
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
117
117
#[ inline]
118
118
pub unsafe fn from_size_align_unchecked ( size : usize , align : usize ) -> Self {
119
119
Layout { size : size, align : align }
120
120
}
121
121
122
122
/// The minimum size in bytes for a memory block of this layout.
123
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
123
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
124
124
#[ inline]
125
125
pub fn size ( & self ) -> usize { self . size }
126
126
127
127
/// The minimum byte alignment for a memory block of this layout.
128
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
128
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
129
129
#[ inline]
130
130
pub fn align ( & self ) -> usize { self . align }
131
131
132
132
/// Constructs a `Layout` suitable for holding a value of type `T`.
133
- #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
133
+ #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
134
+ #[ inline]
134
135
pub fn new < T > ( ) -> Self {
135
136
let ( size, align) = size_align :: < T > ( ) ;
136
137
// Note that the align is guaranteed by rustc to be a power of two and
@@ -146,7 +147,8 @@ impl Layout {
146
147
/// Produces layout describing a record that could be used to
147
148
/// allocate backing structure for `T` (which could be a trait
148
149
/// or other unsized type like a slice).
149
- #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
150
+ #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
151
+ #[ inline]
150
152
pub fn for_value < T : ?Sized > ( t : & T ) -> Self {
151
153
let ( size, align) = ( mem:: size_of_val ( t) , mem:: align_of_val ( t) ) ;
152
154
// See rationale in `new` for why this us using an unsafe variant below
@@ -325,14 +327,14 @@ impl Layout {
325
327
/// The parameters given to `Layout::from_size_align`
326
328
/// or some other `Layout` constructor
327
329
/// do not satisfy its documented constraints.
328
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
330
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
329
331
#[ derive( Clone , PartialEq , Eq , Debug ) ]
330
332
pub struct LayoutErr {
331
333
private : ( )
332
334
}
333
335
334
336
// (we need this for downstream impl of trait Error)
335
- #[ unstable ( feature = "allocator_api " , issue = "32838 " ) ]
337
+ #[ stable ( feature = "alloc_layout " , since = "1.28.0 " ) ]
336
338
impl fmt:: Display for LayoutErr {
337
339
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
338
340
f. write_str ( "invalid parameters to Layout::from_size_align" )
0 commit comments