Ajd' da skratimo primer. Kako proslediti instancu Application-a u UserInterface?
Code:
use std::rc::Rc;
use std::cell::RefCell;
struct Application {
user_interface: Rc<RefCell<UserInterface>>,
all_entries: Vec<String>
}
struct UserInterface {
app: Application,
}
impl Application {
fn new() -> Self {
Self {
user_interface: Rc::new(RefCell::new(UserInterface::new())),
all_entries: vec!["spam".to_string(), "eggs".to_string()]
}
}
}
impl UserInterface {
fn new() -> Self {
Self {
app: ???
}
}
}
fn main() {}
use std::rc::Rc;
use std::cell::RefCell;
struct Application {
user_interface: Rc<RefCell<UserInterface>>,
all_entries: Vec<String>
}
struct UserInterface {
app: Application,
}
impl Application {
fn new() -> Self {
Self {
user_interface: Rc::new(RefCell::new(UserInterface::new())),
all_entries: vec!["spam".to_string(), "eggs".to_string()]
}
}
}
impl UserInterface {
fn new() -> Self {
Self {
app: ???
}
}
}
fn main() {}
[Ovu poruku je menjao clydefrog dana 01.05.2020. u 22:42 GMT+1]