summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2020-05-01 18:46:23 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2020-05-01 22:16:38 +0200
commitfd2384b7fab14732efde99da8affd830e2334e16 (patch)
treea17111e3363c457ec727b52023212c113d8304f6 /src/main.rs
parent5b449f4e1e43bc59109da5a37edf5ec911d3df8e (diff)
downloadneco-fd2384b7fab14732efde99da8affd830e2334e16.tar
neco-fd2384b7fab14732efde99da8affd830e2334e16.zip
Nightly stuff
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 26882ff..fe151fe 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,12 @@
#![no_main]
#![no_std]
+#![feature(alloc_error_handler)]
-use safe_libc as libc;
+mod system_alloc;
+
+extern crate alloc;
use libc::cstr;
+use safe_libc as libc;
use core::fmt::Write;
@@ -19,17 +23,20 @@ pub extern "C" fn main(_nargs: libc::c_int, _args: *const *const libc::c_char) -
let x = libc::string::CString::from("foo");
let l = x.len();
let y = x.into_raw();
- let z = unsafe {
- libc::boxed::CBox::slice_from_raw_parts(y, l)
- };
+ let z = unsafe { alloc::boxed::Box::from_raw(core::ptr::slice_from_raw_parts_mut(y, l)) };
let _ = writeln!(stdout, "Foo: {} {} {}", z[0], z[1], z[2]);
}
{
- let b = libc::boxed::CBox::new(42);
+ let b = alloc::boxed::Box::new(42);
let _ = writeln!(stdout, "Bar: {}", b);
}
+ {
+ let x = alloc::boxed::Box::new(());
+ let _ = writeln!(stdout, "Box: {:?}", x);
+ }
+
0
}