1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/// once timer pub struct Once { /// timer name pub name: String, /// once task pub once: Box<dyn FnOnce() + Send>, } /// custom method impl Once { /// create once timer pub fn new(name: impl Into<String>, task: impl FnOnce() + Send + 'static) -> Self { Self { name: name.into(), once: Box::new(task), } } /*/// create default onec timer pub fn once(task: impl FnOnce() + Send + 'static) -> Self { Self::new("default", task) }*/ }