More stuff compiles

This commit is contained in:
Mia
2026-02-27 15:48:16 +01:00
parent 4b07d93ae3
commit 0b4f169c6f
20 changed files with 552 additions and 134 deletions
+14
View File
@@ -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)
}
}