From 1ed36a3a6bfb4b66cf29ad41e472657148452b79 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 4 Dec 2015 16:10:14 +0100 Subject: [PATCH] Use starts_with to avoid panics. --- src/visitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/visitor.rs b/src/visitor.rs index 7b694de4535..ef422ca5924 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -69,7 +69,7 @@ impl<'a> FmtVisitor<'a> { // Check if this block has braces. let snippet = self.snippet(b.span); - let has_braces = &snippet[..1] == "{" || &snippet[..6] == "unsafe"; + let has_braces = snippet.starts_with("{") || snippet.starts_with("unsafe"); let brace_compensation = if has_braces { BytePos(1) } else {