// Clamp between `PAGE_MIN_SIZE` and `PAGE_MAX_SIZE` to handle the case where
// the existing page is the empty page, and to avoid overly large allocated
// blocks.
- let new_page_size = new_page_size.max(PAGE_MIN_SIZE).min(PAGE_MAX_SIZE);
+ let new_page_size = new_page_size.clamp(PAGE_MIN_SIZE, PAGE_MAX_SIZE);
// Ensure that after all that, the given page is large enough to hold the thing
// we're trying to allocate.
let new_page_size = new_page_size.max(layout.size() + (layout.align() - 1) + PAGE_FOOTER_SIZE);
pub fn with_capacity(capacity: usize, max_capacity: usize) -> Self {
assert!(max_capacity.is_power_of_two());
- assert!(max_capacity < std::isize::MAX as usize);
+ assert!(max_capacity < isize::MAX as usize);
let cap = std::cmp::max(capacity + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
Self {
buf: VirtualRawVec::with_capacity(cap, max_capacity),
let max_capacity_bytes = size.checked_mul(max_capacity).unwrap();
// Check overflow of rounding operation.
- assert!(max_capacity_bytes <= (std::usize::MAX - (align - 1)));
+ assert!(max_capacity_bytes <= (usize::MAX - (align - 1)));
let ptr = virtual_reserve(max_capacity_bytes).expect("mapping failed");
let ptr = unsafe { NonNull::new_unchecked(ptr as *mut T) };
};
pub const NAN: Self = Self {
- a: std::f32::NAN,
- b: std::f32::NAN,
- c: std::f32::NAN,
- d: std::f32::NAN,
+ a: f32::NAN,
+ b: f32::NAN,
+ c: f32::NAN,
+ d: f32::NAN,
};
/// Create a new quaternion from its components.