From e91bf0bba4d0611af81b17430a975656e96006c6 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 10 Jun 2019 03:37:34 +0800 Subject: Use &str instread of Option --- crates/ra_ide_api/src/display.rs | 2 +- crates/ra_ide_api/src/display/navigation_target.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs index 7a8734a75..f11af0a0b 100644 --- a/crates/ra_ide_api/src/display.rs +++ b/crates/ra_ide_api/src/display.rs @@ -78,7 +78,7 @@ where pub(crate) fn doc_text_for(nav: NavigationTarget) -> Option { match (nav.description(), nav.docs()) { (Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)), - (None, Some(docs)) => Some(docs), + (None, Some(docs)) => Some(docs.to_string()), _ => None, } } diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 9b17d6adc..80726efbb 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -54,12 +54,12 @@ impl NavigationTarget { self.full_range } - pub fn docs(&self) -> Option { - self.docs.clone() + pub fn docs(&self) -> Option<&str> { + self.docs.as_ref().map(String::as_str) } - pub fn description(&self) -> Option { - self.description.clone() + pub fn description(&self) -> Option<&str> { + self.description.as_ref().map(String::as_str) } /// A "most interesting" range withing the `full_range`. -- cgit v1.2.3