Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::sync::Arc;
- #[derive(Debug)]
- struct Module {
- foo: bool
- }
- #[derive(Debug)]
- struct Executor {
- module: Module
- }
- impl Executor {
- pub fn load() -> Result<&'static Executor, ()> {
- Ok( &Executor{ module: Module { foo: true } } )
- }
- }
- #[derive(Debug)]
- struct ExecutorArc {
- module: Arc<Module>
- }
- impl ExecutorArc {
- pub fn load() -> Result<&'static ExecutorArc, ()> {
- Ok( &ExecutorArc { module: Arc::new( Module { foo: true } ) } )
- }
- }
- fn main() {
- let executor = Executor::load().unwrap();
- println!("executor = {:?}", executor);
- let executor_arc = ExecutorArc::load().unwrap();
- println!("executor_arc = {:?}", executor_arc);
- }
Add Comment
Please, Sign In to add comment