See examples/01a.rs
for the full example.
```rust
struct GUIInternal {
running: bool,
eventrecv: Receiver
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
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()
}
} ```
See examples/01b.rs
for the full example.
```rust
rcstruct::rcstruct! {
pub struct GUI {
running: bool,
eventrecv: Receiver
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)
}
}
} ```
Licensed under either of
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.