update async-std 0.99.10

This commit is contained in:
wyhaya
2019-10-28 11:32:20 +08:00
parent 3fcf503a4f
commit 54c990725a
4 changed files with 88 additions and 14 deletions

View File

@@ -111,6 +111,8 @@ pub struct Config {
file: File,
}
// todo
// async
impl Config {
pub fn new<P: AsRef<Path>>(path: P) -> io::Result<Config> {
let path = path.as_ref();

View File

@@ -2,7 +2,6 @@ use async_std::fs;
use async_std::io;
use async_std::prelude::*;
use async_std::stream;
use async_std::task;
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
@@ -22,16 +21,16 @@ impl Watch {
Ok(modified)
}
// todo
// use Stream
pub async fn for_each(&mut self, func: fn(path: &PathBuf)) {
let mut repeat = stream::repeat(0);
let mut before = match self.modified().await {
Ok(time) => Some(time),
Err(_) => None,
};
while let Some(_) = repeat.next().await {
task::sleep(Duration::from_millis(self.interval)).await;
let mut interval = stream::interval(Duration::from_millis(self.interval));
while let Some(_) = interval.next().await {
let after = match self.modified().await {
Ok(time) => Some(time),
Err(_) => None,