From c476742f47dd905fa366e62f480e3f656c62e66c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 10 Apr 2020 17:47:49 +0200 Subject: Simplify --- crates/ra_syntax/src/ast/extensions.rs | 20 +------------------- crates/ra_syntax/src/ast/generated/nodes.rs | 1 + 2 files changed, 2 insertions(+), 19 deletions(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 1aacb0676..76b7655e6 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -275,7 +275,7 @@ pub enum SelfParamKind { impl ast::SelfParam { pub fn kind(&self) -> SelfParamKind { if self.amp_token().is_some() { - if self.amp_mut_token().is_some() { + if self.mut_token().is_some() { SelfParamKind::MutRef } else { SelfParamKind::Ref @@ -284,24 +284,6 @@ impl ast::SelfParam { SelfParamKind::Owned } } - - /// the "mut" in "mut self", not the one in "&mut self" - pub fn mut_token(&self) -> Option { - self.syntax() - .children_with_tokens() - .filter_map(|it| it.into_token()) - .take_while(|it| it.kind() != T![&]) - .find(|it| it.kind() == T![mut]) - } - - /// the "mut" in "&mut self", not the one in "mut self" - pub fn amp_mut_token(&self) -> Option { - self.syntax() - .children_with_tokens() - .filter_map(|it| it.into_token()) - .skip_while(|it| it.kind() != T![&]) - .find(|it| it.kind() == T![mut]) - } } #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 0df7cfe52..f1098755b 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -2307,6 +2307,7 @@ impl ast::TypeAscriptionOwner for SelfParam {} impl ast::AttrsOwner for SelfParam {} impl SelfParam { pub fn amp_token(&self) -> Option { support::token(&self.syntax, T![&]) } + pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } pub fn lifetime_token(&self) -> Option { support::token(&self.syntax, T![lifetime]) } -- cgit v1.2.3