izmenjeno 1 put, poslednji put clydefrog 01.05.2020. u 22:42
Izmene poruke
- clydefrog01.05.2020. u 22:42zapis iz teksta poruke
Bane, hvala sto si se javio.
Ajd' da skratimo primer. Kako proslediti instancu Application-a u UserInterface?
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() {}