mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 07:46:29 +00:00
Merge pull request #117 from shaunbennett/master
Watch for file creation events in watch mode
This commit is contained in:
commit
7d6e2812fb
1 changed files with 5 additions and 2 deletions
|
@ -3,6 +3,7 @@ use crate::verify::verify;
|
||||||
use clap::{crate_version, App, Arg, SubCommand};
|
use clap::{crate_version, App, Arg, SubCommand};
|
||||||
use notify::DebouncedEvent;
|
use notify::DebouncedEvent;
|
||||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -85,8 +86,10 @@ fn watch() -> notify::Result<()> {
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
Ok(event) => match event {
|
Ok(event) => match event {
|
||||||
DebouncedEvent::Chmod(_) | DebouncedEvent::Write(_) => {
|
DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
|
||||||
let _ignored = verify();
|
if b.extension() == Some(OsStr::new("rs")) {
|
||||||
|
let _ignored = verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue