From a01a99423168ffd3ef3003c328056dc09804f1ce Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 9 Oct 2018 14:30:14 +0200 Subject: A handful of random string-related improvements --- src/librustc_errors/diagnostic.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 2799f2cc81f..870eeadc081 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -76,9 +76,9 @@ pub enum StringPart { } impl StringPart { - pub fn content(&self) -> String { + pub fn content(&self) -> &str { match self { - &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s.to_owned() + &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s } } } @@ -398,7 +398,7 @@ impl Diagnostic { } pub fn message(&self) -> String { - self.message.iter().map(|i| i.0.to_owned()).collect::() + self.message.iter().map(|i| i.0.as_str()).collect::() } pub fn styled_message(&self) -> &Vec<(String, Style)> { @@ -448,7 +448,7 @@ impl Diagnostic { impl SubDiagnostic { pub fn message(&self) -> String { - self.message.iter().map(|i| i.0.to_owned()).collect::() + self.message.iter().map(|i| i.0.as_str()).collect::() } pub fn styled_message(&self) -> &Vec<(String, Style)> { -- cgit 1.4.1-3-g733a5