Guest User

Untitled

a guest
Jan 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. use std::sync::Arc;
  2.  
  3. #[derive(Debug)]
  4. struct Module {
  5. foo: bool
  6. }
  7.  
  8. #[derive(Debug)]
  9. struct Executor {
  10. module: Module
  11. }
  12.  
  13. impl Executor {
  14. pub fn load() -> Result<&'static Executor, ()> {
  15. Ok( &Executor{ module: Module { foo: true } } )
  16. }
  17. }
  18.  
  19. #[derive(Debug)]
  20. struct ExecutorArc {
  21. module: Arc<Module>
  22. }
  23.  
  24. impl ExecutorArc {
  25. pub fn load() -> Result<&'static ExecutorArc, ()> {
  26. Ok( &ExecutorArc { module: Arc::new( Module { foo: true } ) } )
  27. }
  28. }
  29.  
  30. fn main() {
  31. let executor = Executor::load().unwrap();
  32. println!("executor = {:?}", executor);
  33.  
  34. let executor_arc = ExecutorArc::load().unwrap();
  35. println!("executor_arc = {:?}", executor_arc);
  36. }
Add Comment
Please, Sign In to add comment