More stuff compiles
This commit is contained in:
@@ -37,10 +37,24 @@ impl<'l> dyn Allocator + 'l {
|
||||
&mut *(self.alloc_unsafe(data, layout, drop) as *mut T)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_str(&'l self, str: &str) -> &'l str {
|
||||
unsafe {
|
||||
let ptr =
|
||||
self.alloc_unsafe(str.as_ptr(), Layout::array::<u8>(str.len()).unwrap(), None);
|
||||
let slice = std::slice::from_raw_parts_mut(ptr, str.len());
|
||||
slice.copy_from_slice(str.as_bytes());
|
||||
std::str::from_utf8_unchecked(slice)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'l> dyn SyncAllocator + 'l {
|
||||
pub fn alloc<T: Send>(&'l self, value: T) -> &'l mut T {
|
||||
<dyn Allocator>::alloc(self, value)
|
||||
}
|
||||
|
||||
pub fn alloc_str(&'l self, value: &str) -> &'l str {
|
||||
<dyn Allocator>::alloc_str(self, value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user