Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. struct AppState<'a> {
  2. services: &'a AppServices<'a>,
  3. }
  4.  
  5. impl<'a> AppState<'a> {
  6. pub fn new() -> Self {
  7. AppState {
  8. services: &AppServices { id: None },
  9. }
  10. }
  11. }
  12.  
  13. struct AppServices<'a> {
  14. id: Option<&'a IdService<'a>>,
  15. }
  16.  
  17. struct IdService<'a> {
  18. name: String,
  19. state: &'a AppState<'a>,
  20. }
  21.  
  22.  
  23.  
  24. fn main() {
  25. let mut state = AppState::new();
  26. let id_service = IdService{name: "test".to_string(), state: &state};
  27. state.services = &AppServices{id: Some(&id_service)};
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement