From 98f98cbb5404385703a404547aa2477d4a2fd1cb Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 13 Dec 2019 21:53:34 +0800 Subject: Refactor tt::Delimiter --- crates/ra_tt/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/ra_tt') diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 4c00b8f30..e7bfd5fd2 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -48,9 +48,9 @@ pub enum Leaf { } impl_froms!(Leaf: Literal, Punct, Ident); -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct Subtree { - pub delimiter: Delimiter, + pub delimiter: Option, pub token_trees: Vec, } @@ -59,7 +59,6 @@ pub enum Delimiter { Parenthesis, Brace, Bracket, - None, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -97,10 +96,10 @@ 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 { - Delimiter::Parenthesis => ("(", ")"), - Delimiter::Brace => ("{", "}"), - Delimiter::Bracket => ("[", "]"), - Delimiter::None => ("", ""), + Some(Delimiter::Parenthesis) => ("(", ")"), + Some(Delimiter::Brace) => ("{", "}"), + Some(Delimiter::Bracket) => ("[", "]"), + None => ("", ""), }; f.write_str(l)?; let mut needs_space = false; -- cgit v1.2.3