From 24f4b151b11b22b66ac0128f76c1e12cca45b178 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 26 Apr 2016 13:36:30 -0400 Subject: [PATCH] Nit: use last_mut better --- src/libsyntax/errors/snippet/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/errors/snippet/mod.rs b/src/libsyntax/errors/snippet/mod.rs index ada336b29a4..0c8b4f2046a 100644 --- a/src/libsyntax/errors/snippet/mod.rs +++ b/src/libsyntax/errors/snippet/mod.rs @@ -229,10 +229,9 @@ impl From<(S1, Style, S2, Style, RenderedLineKind)> for RenderedLine impl RenderedLine { fn trim_last(&mut self) { - if !self.text.is_empty() { - let last_text = &mut self.text.last_mut().unwrap().text; - let len = last_text.trim_right().len(); - last_text.truncate(len); + if let Some(last_text) = self.text.last_mut() { + let len = last_text.text.trim_right().len(); + last_text.text.truncate(len); } } }