From d9c9f6dc2cd3080009c4ce2c3f0f340949f4f53c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 9 May 2021 17:58:03 +0300 Subject: cleanups --- crates/ide_assists/src/utils/suggest_name.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/ide_assists/src/utils/suggest_name.rs') diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs index deafcd630..c8487846d 100644 --- a/crates/ide_assists/src/utils/suggest_name.rs +++ b/crates/ide_assists/src/utils/suggest_name.rs @@ -6,7 +6,7 @@ use itertools::Itertools; use stdx::to_lower_snake_case; use syntax::{ ast::{self, NameOwner}, - match_ast, AstNode, + match_ast, AstNode, SmolStr, }; /// Trait names, that will be ignored when in `impl Trait` and `dyn Trait` @@ -57,6 +57,14 @@ const USELESS_METHODS: &[&str] = &[ "iter_mut", ]; +pub(crate) fn generic_parameter(ty: &ast::ImplTraitType) -> SmolStr { + let c = ty + .type_bound_list() + .and_then(|bounds| bounds.syntax().text().char_at(0.into())) + .unwrap_or('T'); + c.encode_utf8(&mut [0; 4]).into() +} + /// Suggest name of variable for given expression /// /// **NOTE**: it is caller's responsibility to guarantee uniqueness of the name. -- cgit v1.2.3