Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct Watcher{
- dir: String,
- rules: Vec<Rule>,
- handle: Option<thread::JoinHandle<()>>,
- running: bool
- }
- impl Watcher{
- fn start(&mut self){
- self.running = true;
- let cself = Arc::new(self);
- let t = thread::spawn(move || {
- loop{
- if cself.running == false{
- break
- }
- println!("Ama tread");
- thread::sleep(Duration::from_secs(2));
- }
- });
- self.handle = Some(t);
- }
- }
- ERRORS:
- error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
- --> src/watch.rs:35:30
- |
- 35 | let cself = Arc::new(self);
- | ^^^^
- |
- note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 32:5...
- --> src/watch.rs:32:5
- |
- 32 | / fn start(&mut self){
- 33 | | self.running = true;
- 34 | |
- 35 | | let cself = Arc::new(self);
- ... |
- 47 | | self.handle = Some(t);
- 48 | | }
- | |_____^
- = note: ...so that the expression is assignable:
- expected &mut watch::Watcher
- found &mut watch::Watcher
- = note: but, the lifetime must be valid for the static lifetime...
- note: ...so that the type `[closure@src/watch.rs:36:31: 46:10 cself:std::sync::Arc<&mut watch::Watcher>]` will meet its required lifetime bounds
- --> src/watch.rs:36:17
- |
- 36 | let t = thread::spawn(move || {
- | ^^^^^^^^^^^^^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement