From e7300dc5f2c0787623286d83d54f6a26b08ff907 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 27 Mar 2021 17:25:51 -0600 Subject: use Self more often in token --- src/makefile/token.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/makefile/token.rs b/src/makefile/token.rs index 4fde3e5..811f30f 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -27,7 +27,7 @@ impl TokenString { &mut self.0[0] } - pub(crate) fn split_once(&self, delimiter: char) -> Option<(TokenString, TokenString)> { + pub(crate) fn split_once(&self, delimiter: char) -> Option<(Self, Self)> { let mut result0 = vec![]; let mut iter = self.0.iter(); while let Some(t) = iter.next() { @@ -39,7 +39,7 @@ impl TokenString { result0.push(Token::Text(pieces[0].into())); let mut result1 = vec![Token::Text(pieces[1].into())]; result1.extend(iter.cloned()); - return Some((TokenString(result0), TokenString(result1))); + return Some((Self(result0), Self(result1))); } _ => result0.push(t.clone()), } @@ -62,7 +62,7 @@ impl TokenString { } } - pub(crate) fn extend(&mut self, other: TokenString) { + pub(crate) fn extend(&mut self, other: Self) { self.0.extend(other.0); } @@ -94,12 +94,12 @@ pub(crate) enum Token { impl fmt::Display for Token { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Token::Text(t) => write!(f, "{}", t), - Token::MacroExpansion { + Self::Text(t) => write!(f, "{}", t), + Self::MacroExpansion { name, replacement: None, } => write!(f, "$({})", name), - Token::MacroExpansion { + Self::MacroExpansion { name, replacement: Some((r1, r2)), } => write!(f, "$({}:{}={})", name, r1, r2), -- cgit v1.2.3