Use unchecked construction in Layout::pad_to_align
.
Other, similar methods for `Layout` do likewise, and there's already an `unwrap()` around the result demonstrating the safety.
This commit is contained in:
parent
8a48b376d5
commit
026edbb4ef
1 changed files with 3 additions and 1 deletions
|
@ -281,7 +281,9 @@ impl Layout {
|
|||
// > `usize::MAX`)
|
||||
let new_size = self.size() + pad;
|
||||
|
||||
Layout::from_size_align(new_size, self.align()).unwrap()
|
||||
// SAFETY: self.align is already known to be valid and new_size has been
|
||||
// padded already.
|
||||
unsafe { Layout::from_size_align_unchecked(new_size, self.align()) }
|
||||
}
|
||||
|
||||
/// Creates a layout describing the record for `n` instances of
|
||||
|
|
Loading…
Add table
Reference in a new issue