WIP: Track grant ownership.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::memory::Enomem;
|
||||
|
||||
pub mod aligned_box;
|
||||
#[macro_use]
|
||||
pub mod int_like;
|
||||
@@ -26,3 +31,14 @@ macro_rules! dbg {
|
||||
($($crate::dbg!($val)),+,)
|
||||
};
|
||||
}
|
||||
|
||||
pub fn try_new_vec_with_exact_size<T>(len: usize) -> Result<Vec<T>, Enomem> {
|
||||
let mut vec = Vec::new();
|
||||
vec.try_reserve_exact(len).map_err(|_| Enomem)?;
|
||||
Ok(vec.into())
|
||||
}
|
||||
pub fn try_box_slice_new<T: Clone>(value: T, len: usize) -> Result<Box<[T]>, Enomem> {
|
||||
let mut vec = try_new_vec_with_exact_size(len)?;
|
||||
vec.resize(len, value);
|
||||
Ok(vec.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user