From 41544a40883874553f570e2999bf56d172bd6246 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 18 Dec 2019 11:47:26 +0800 Subject: Refactoring --- crates/ra_tt/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_tt/src') diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 73d8395a8..10f424aae 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -103,7 +103,7 @@ impl fmt::Display for TokenTree { impl fmt::Display for Subtree { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let (l, r) = match self.delimiter.map(|it| it.kind) { + let (l, r) = match self.delimiter_kind() { Some(DelimiterKind::Parenthesis) => ("(", ")"), Some(DelimiterKind::Brace) => ("{", "}"), Some(DelimiterKind::Bracket) => ("[", "]"), @@ -171,6 +171,10 @@ impl Subtree { self.token_trees.len() + children_count } + + pub fn delimiter_kind(&self) -> Option { + self.delimiter.map(|it| it.kind) + } } pub mod buffer; -- cgit v1.2.3