1
Fork 0

add Align::ONE; add methods to access alloc.extra

This commit is contained in:
Ralf Jung 2021-05-17 13:08:12 +02:00
parent 74995c4292
commit 563ab4a106
6 changed files with 30 additions and 19 deletions

View file

@ -441,6 +441,8 @@ pub struct Align {
}
impl Align {
pub const ONE: Align = Align { pow2: 0 };
#[inline]
pub fn from_bits(bits: u64) -> Result<Align, String> {
Align::from_bytes(Size::from_bits(bits).bytes())
@ -450,7 +452,7 @@ impl Align {
pub fn from_bytes(align: u64) -> Result<Align, String> {
// Treat an alignment of 0 bytes like 1-byte alignment.
if align == 0 {
return Ok(Align { pow2: 0 });
return Ok(Align::ONE);
}
#[cold]