From 3ce531f95dec87a1f59e9347fdd6c250e36b489d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 16:40:24 +0300 Subject: cleanup: add result alias --- crates/ra_vfs/src/io.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs index 84ccdb394..279fa5da8 100644 --- a/crates/ra_vfs/src/io.rs +++ b/crates/ra_vfs/src/io.rs @@ -1,11 +1,11 @@ use std::{ fs, + thread, path::{Path, PathBuf}, sync::{mpsc, Arc}, - thread, time::Duration, }; -use crossbeam_channel::{Receiver, Sender, SendError}; +use crossbeam_channel::{Receiver, Sender}; use relative_path::RelativePathBuf; use thread_worker::WorkerHandle; use walkdir::WalkDir; @@ -14,6 +14,8 @@ use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher as _Watc use crate::{RootConfig, Roots, VfsRoot}; +type Result = std::result::Result>; + pub(crate) enum Task { AddRoot { root: VfsRoot, @@ -112,11 +114,7 @@ impl Worker { } } -fn watch_root( - woker: &WatcherCtx, - root: VfsRoot, - config: Arc, -) -> Result<(), SendError> { +fn watch_root(woker: &WatcherCtx, root: VfsRoot, config: Arc) -> Result<()> { let mut guard = woker.watcher.lock(); log::debug!("loading {} ...", config.root.as_path().display()); let files = watch_recursive(guard.as_mut(), config.root.as_path(), &*config) @@ -142,7 +140,7 @@ struct WatcherCtx { } impl WatcherCtx { - fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<(), SendError> { + fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<()> { match ev { DebouncedEvent::NoticeWrite(_) | DebouncedEvent::NoticeRemove(_) @@ -173,7 +171,7 @@ impl WatcherCtx { Ok(()) } - fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<(), SendError> { + fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<()> { let (root, rel_path) = match self.roots.find(&path) { None => return Ok(()), Some(it) => it, -- cgit v1.2.3