Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::cell::Cell;
- #[derive(Copy, Clone, Debug)]
- enum Pin {
- P1,
- P2,
- P3
- }
- struct SharedPins {
- p1: Pin,
- p2: Pin
- }
- fn main() {
- let spc = Cell::new(None);
- let conf = setup(&spc);
- println!("{:?}", conf);
- }
- fn setup(spc: &Cell<Option <SharedPins>>) -> (&Pin, &Pin, Pin) {
- spc.set(Some(SharedPins{p1: Pin::P1, p2: Pin::P2}));
- let sp = unsafe {&*(spc.as_ptr() as *mut SharedPins)};
- (&sp.p1, &sp.p2, Pin::P3)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement