rcstruct

Example without rcstruct

See examples/01a.rs for the full example.

```rust struct GUIInternal { running: bool, eventrecv: Receiver, actionsend: Sender, }

impl GUIInternal { fn sendaction(&self, action: Action) -> Rt { Ok(self.actionsend.send(action)?) }

fn running(&self) -> Rt<bool> {
    Ok(self.running)
}

fn quit(&mut self) -> Rt {
    self.running = false;
    Ok(())
}

fn events(&self) -> Rt<impl IntoIterator<Item = Event>> {
    let events = Vec::new();
    Ok(events)
}

}

pub struct GUI(Rc>);

impl GUI { pub fn new(eventrecv: Receiver, actionsend: Sender) -> Rt { let running = true; Ok(GUI(Rc::new(RefCell::new(GUIInternal { running, eventrecv, actionsend, })))) }

pub fn send_action(&self, action: Action) -> Rt {
    self.0.borrow().send_action(action)
}

pub fn running(&self) -> Rt<bool> {
    self.0.borrow().running()
}

pub fn quit(&self) -> Rt {
    self.0.borrow_mut().quit()
}

pub fn events(&self) -> Rt<impl IntoIterator<Item = Event>> {
    self.0.borrow().events()
}

} ```

Example with rcstruct

See examples/01b.rs for the full example.

```rust rcstruct::rcstruct! { pub struct GUI { running: bool, eventrecv: Receiver, actionsend: Sender, }

impl {
    pub new(event_recv: Receiver<Event>, action_send: Sender<Action>) -> Rt<Self> {
        let running = true;
        { running, event_recv, action_send, }
    }

    pub fn send_action(&self, action: Action) -> Rt {
        Ok(self.action_send.send(action)?)
    }

    pub fn running(&self) -> Rt<bool> {
        Ok(self.running)
    }

    pub fn quit(&mut self) -> Rt {
        self.running = false;
        Ok(())
    }

    pub fn events(&self) -> Rt<impl IntoIterator<Item = Event>> {
        let events = Vec::new();
        Ok(events)
    }
}

} ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.