#[repr(C)] #[derive(Default)] struct SendableThing { one: usize, two: u32, three: u8, four: u16, } // #[repr(C)] // struct UnSendableThing { // badness: *const u8, // } #[xous::xous_main] fn main() -> ! { // let mut unsendable = xous::ipc::Sendable::new(UnSendableThing { // badness: 4 as *const u8, // }); // Allocate an uninitialized SendableThing. Note we must explicitly call out what it is // we're constructing, since it's ambiguous. This is the Turbofish operator (i.e. ::) let _st1_uninit = xous::ipc::UninitializedSendable::::uninit().unwrap(); // {{{something here involving uninitialized values}}} let _st1 = unsafe { _st1_uninit.assume_init() }; // Pass a default value to the constructor let mut _st2 = xous::ipc::Sendable::new(SendableThing { one: 1, two: 10, three: 3, four: 4, }).unwrap(); // Note that you can mostly ignore the `SendableThing` wrapper and // directly manipulate fields. _st2.two = 2; _st2.four += 1; // Since this implements `Default`, we can just call the `default()` constructor. // This also uses Turbofish. let _st3 = xous::ipc::Sendable::::default(); // It's also possible to simply be explicit about what type we want. let _st4: xous::ipc::Sendable = xous::ipc::Sendable::default(); loop {} }