]> git.lizzy.rs Git - rust.git/commitdiff
cleanup: add result alias
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 26 Jan 2019 13:40:24 +0000 (16:40 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 26 Jan 2019 13:40:24 +0000 (16:40 +0300)
crates/ra_vfs/src/io.rs

index 84ccdb394df5ebf2236e985aa913f8a1f9ca7dc7..279fa5da8d2e9c94a18ff31706d131941bddd339 100644 (file)
@@ -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 crate::{RootConfig, Roots, VfsRoot};
 
+type Result<T> = std::result::Result<T, crossbeam_channel::SendError<TaskResult>>;
+
 pub(crate) enum Task {
     AddRoot {
         root: VfsRoot,
@@ -112,11 +114,7 @@ pub(crate) fn shutdown(self) -> thread::Result<()> {
     }
 }
 
-fn watch_root(
-    woker: &WatcherCtx,
-    root: VfsRoot,
-    config: Arc<RootConfig>,
-) -> Result<(), SendError<TaskResult>> {
+fn watch_root(woker: &WatcherCtx, root: VfsRoot, config: Arc<RootConfig>) -> 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<TaskResult>> {
+    fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<()> {
         match ev {
             DebouncedEvent::NoticeWrite(_)
             | DebouncedEvent::NoticeRemove(_)
@@ -173,7 +171,7 @@ fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<(), SendError<Tas
         Ok(())
     }
 
-    fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<(), SendError<TaskResult>> {
+    fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<()> {
         let (root, rel_path) = match self.roots.find(&path) {
             None => return Ok(()),
             Some(it) => it,