daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top