Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample on crates.io has a borrow error. #9

Closed
davehorner opened this issue Feb 9, 2022 · 1 comment
Closed

sample on crates.io has a borrow error. #9

davehorner opened this issue Feb 9, 2022 · 1 comment

Comments

@davehorner
Copy link

https://crates.io/crates/tokio-cron-scheduler
I copied and pasted the code from the webpage. When I build I get:

error[E0382]: borrow of moved value: `jj`
  --> src\main.rs:33:5
   |
28 |       let mut jj = Job::new_repeated(Duration::from_secs(8), |_uuid, _l| {
   |           ------ move occurs because `jj` has type `Job`, which does not implement the `Copy` trait
...
31 |       sched.add(jj);
   |                 -- value moved here
32 |
33 | /     jj.on_start_notification_add(Box::new(|job_id, notification_id, type_of_notification| {
34 | |       Box::pin(async move {
35 | |         println!("Job {:?} was started, notification {:?} ran ({:?})", job_id, notification_id, type_of_notification);
36 | |       })
37 | |     }));
   | |_______^ value borrowed here after move

if I jj.clone() that compiles; but it isn't right. I don't need that to work for my purposes, but I wanted to report it and learn something new if there's a solution.

thanks.
--dave

@mvniekerk
Copy link
Owner

Hi @davehorner
Thank you for the bug report. I've updated the README accordingly. Kindly check if this works for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants