2021-05-09 05:26:59 +04:30
|
|
|
use std::alloc::{GlobalAlloc, Layout};
|
|
|
|
|
|
|
|
struct Test(u32);
|
|
|
|
|
|
|
|
unsafe impl GlobalAlloc for Test {
|
|
|
|
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
|
2021-05-11 08:50:43 +04:30
|
|
|
self.0 += 1; //~ ERROR cannot assign
|
2021-05-09 05:26:59 +04:30
|
|
|
0 as *mut u8
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|