/// requests have positive size. A caller to the `Alloc::alloc`
/// method must either ensure that conditions like this are met, or
/// use specific allocators with looser requirements.)
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Layout {
// size of the requested block of memory, measured in bytes.
/// * `size`, when rounded up to the nearest multiple of `align`,
/// must not overflow (i.e. the rounded value must be less than
/// `usize::MAX`).
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> {
if !align.is_power_of_two() {
///
/// This function is unsafe as it does not verify the preconditions from
/// [`Layout::from_size_align`](#method.from_size_align).
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
Layout { size_: size, align_: NonZeroUsize::new_unchecked(align) }
}
/// The minimum size in bytes for a memory block of this layout.
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub fn size(&self) -> usize { self.size_ }
/// The minimum byte alignment for a memory block of this layout.
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub fn align(&self) -> usize { self.align_.get() }
/// Constructs a `Layout` suitable for holding a value of type `T`.
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub fn new<T>() -> Self {
let (size, align) = size_align::<T>();
/// Produces layout describing a record that could be used to
/// allocate backing structure for `T` (which could be a trait
/// or other unsized type like a slice).
- #[unstable(feature = "allocator_api", issue = "32838")]
+ #[stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub fn for_value<T: ?Sized>(t: &T) -> Self {
let (size, align) = (mem::size_of_val(t), mem::align_of_val(t));
/// The parameters given to `Layout::from_size_align`
/// or some other `Layout` constructor
/// do not satisfy its documented constraints.
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct LayoutErr {
private: ()
}
// (we need this for downstream impl of trait Error)
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
impl fmt::Display for LayoutErr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("invalid parameters to Layout::from_size_align")