use std::path::PathBuf; use languageserver_types::{TextDocumentItem, VersionedTextDocumentIdentifier, TextDocumentIdentifier}; use ::{Result}; pub trait FnBox: Send { fn call_box(self: Box, a: A) -> R; } impl R + Send> FnBox for F { fn call_box(self: Box, a: A) -> R { (*self)(a) } } pub trait FilePath { fn file_path(&self) -> Result; } impl FilePath for TextDocumentItem { fn file_path(&self) -> Result { self.uri.file_path() } } impl FilePath for VersionedTextDocumentIdentifier { fn file_path(&self) -> Result { self.uri.file_path() } } impl FilePath for TextDocumentIdentifier { fn file_path(&self) -> Result { self.uri.file_path() } } impl FilePath for ::url::Url { fn file_path(&self) -> Result { self.to_file_path() .map_err(|()| format_err!("invalid uri: {}", self)) } }