From cba694c60276f7543ee9ed1dddf3fe93209f527f Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 8 Apr 2020 19:26:47 -0400 Subject: better `&mut ` and `&` matching --- crates/ra_ide/src/inlay_hints.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 6b8b5813d..1da61e4c4 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -236,13 +236,13 @@ fn should_show_param_hint( argument: &ast::Expr, ) -> bool { let argument_string = { - let arg_string = argument.syntax().to_string(); - let arg_split: Vec = arg_string.chars().collect(); - match arg_split.as_slice() { - ['&', 'm', 'u', 't', ' ', arg_name @ ..] => arg_name.into_iter().collect::(), - ['&', arg_name @ ..] => arg_name.into_iter().collect::(), - _ => arg_string, + let mut arg_string = argument.syntax().to_string(); + if arg_string.get(0..5) == Some("&mut ") { + arg_string = arg_string[5..].to_string(); + } else if arg_string.get(0..1) == Some("&") { + arg_string = arg_string[1..].to_string(); } + arg_string }; if param_name.is_empty() || argument_string.ends_with(¶m_name) -- cgit v1.2.3