1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use core::{alloc::AllocError, hash::Hash, mem::swap, ops::Range};
use crate::error::{Error, Result};
use alloc::{
collections::{TryReserveError, VecDeque},
sync::Arc,
vec::Vec,
};
#[inline]
pub fn round_down(x: usize, n: usize) -> usize {
x - (x % n)
}
#[inline]
pub fn round_up(x: usize, n: usize) -> usize {
round_down(x + n - 1, n)
}
#[inline]
pub fn intersect<T: Ord>(a: &Range<T>, b: &Range<T>) -> bool {
a.start < b.end && a.end > b.start
}
#[macro_export]
macro_rules! from_bytes {
($type:ty, $slice:expr) => {
<$type>::from_le_bytes($slice.try_into().unwrap())
};
}