Skip to content

Commit 1d04baa

Browse files
martskinsautozimu
authored andcommitted
Drop OptionDeref in favor of the now stable Option::as_deref
1 parent 2a8eee4 commit 1d04baa

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

src/rpchandler.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::types::OptionDeref;
21
use super::*;
32
use crate::language_client::LanguageClient;
43
use crate::lsp::notification::Notification;
@@ -8,7 +7,7 @@ impl LanguageClient {
87
pub fn handle_call(&self, msg: Call) -> Fallible<()> {
98
match msg {
109
Call::MethodCall(lang_id, method_call) => {
11-
let result = self.handle_method_call(OptionDeref::as_deref(&lang_id), &method_call);
10+
let result = self.handle_method_call(lang_id.as_deref(), &method_call);
1211
if let Err(ref err) = result {
1312
if err.find_root_cause().downcast_ref::<LCError>().is_none() {
1413
error!(
@@ -23,8 +22,7 @@ impl LanguageClient {
2322
.output(method_call.id.to_int()?, result)?;
2423
}
2524
Call::Notification(lang_id, notification) => {
26-
let result =
27-
self.handle_notification(OptionDeref::as_deref(&lang_id), &notification);
25+
let result = self.handle_notification(lang_id.as_deref(), &notification);
2826
if let Err(ref err) = result {
2927
if err.downcast_ref::<LCError>().is_none() {
3028
error!(

src/types.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -956,16 +956,6 @@ impl Default for TextDocumentItemMetadata {
956956
}
957957
}
958958

959-
pub trait OptionDeref<T: Deref> {
960-
fn as_deref(&self) -> Option<&T::Target>;
961-
}
962-
963-
impl<T: Deref> OptionDeref<T> for Option<T> {
964-
fn as_deref(&self) -> Option<&T::Target> {
965-
self.as_ref().map(Deref::deref)
966-
}
967-
}
968-
969959
pub trait ToLSP<T> {
970960
fn to_lsp(self) -> Fallible<T>;
971961
}

src/vim.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::types::OptionDeref;
21
use super::*;
32
use crate::rpcclient::RpcClient;
43
use crate::sign::Sign;
@@ -149,7 +148,7 @@ impl Vim {
149148

150149
pub fn edit(&self, goto_cmd: &Option<String>, path: impl AsRef<Path>) -> Fallible<()> {
151150
let path = path.as_ref().to_string_lossy();
152-
let goto = OptionDeref::as_deref(goto_cmd).unwrap_or("edit");
151+
let goto = goto_cmd.as_deref().unwrap_or("edit");
153152
self.rpcclient.notify("s:Edit", json!([goto, path]))?;
154153
Ok(())
155154
}

0 commit comments

Comments
 (0)