let var_name = match &field_shorthand {
Some(it) => it.to_string(),
- None => suggest_name::variable(&to_extract, &ctx.sema),
+ None => suggest_name::for_variable(&to_extract, &ctx.sema),
};
let expr_range = match &field_shorthand {
Some(it) => it.syntax().text_range().cover(to_extract.syntax().text_range()),
"Replace impl trait with generic",
target,
|edit| {
- let type_param_name = suggest_name::generic_parameter(&impl_trait_type);
+ let type_param_name = suggest_name::for_generic_parameter(&impl_trait_type);
let generic_param_list = fn_
.generic_param_list()
"iter_mut",
];
-pub(crate) fn generic_parameter(ty: &ast::ImplTraitType) -> SmolStr {
+pub(crate) fn for_generic_parameter(ty: &ast::ImplTraitType) -> SmolStr {
let c = ty
.type_bound_list()
.and_then(|bounds| bounds.syntax().text().char_at(0.into()))
/// It also applies heuristics to filter out less informative names
///
/// Currently it sticks to the first name found.
-pub(crate) fn variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String {
+// FIXME: Microoptimize and return a `SmolStr` here.
+pub(crate) fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String {
// `from_param` does not benifit from stripping
// it need the largest context possible
// so we check firstmost
frange.range,
"selection is not an expression(yet contained in one)"
);
- let name = variable(&expr, &sema);
+ let name = for_variable(&expr, &sema);
assert_eq!(&name, expected);
}