mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
17 lines
336 B
Rust
17 lines
336 B
Rust
use std::alloc::{GlobalAlloc, Layout};
|
|
|
|
struct Test(u32);
|
|
|
|
unsafe impl GlobalAlloc for Test {
|
|
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
|
|
self.0 += 1; //~ ERROR cannot assign
|
|
0 as *mut u8
|
|
}
|
|
|
|
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
|
|
unimplemented!();
|
|
}
|
|
}
|
|
|
|
fn main() { }
|