Skip to main content

Module utils

Module utils 

Source
Expand description

Assorted functions shared by several assists.

ModulesΒ§

gen_trait_fn_body πŸ”’
This module contains functions to generate default trait impl function bodies where possible.
ref_field_expr πŸ”’
This module contains a helper for converting a field access expression into a path expression. This is used when destructuring a tuple or struct.

StructsΒ§

ReferenceConversion πŸ”’

EnumsΒ§

DefaultMethods
IgnoreAssocItems
ReferenceConversionType πŸ”’

FunctionsΒ§

add_group_separators πŸ”’
add_trait_assoc_items_to_impl
Given original_items retrieved from the trait definition (usually by filter_assoc_items()), clones each item for update and applies path transformation to it, then inserts into impl_. Returns the modified impl_ and the first associated item that got inserted.
check_pat_variant_from_enum πŸ”’
check_pat_variant_nested_or_literal_with_depth πŸ”’
convert_param_list_to_arg_list πŸ”’
Convert a list of function params to a list of arguments that can be passed into a function call.
convert_reference_type πŸ”’
could_deref_to_target πŸ”’
cover_edit_range πŸ”’
cover_let_chain πŸ”’
does_pat_match_variant πŸ”’
does_pat_variant_nested_or_literal πŸ”’
expr_fill_default πŸ”’
extract_trivial_expression
filter_assoc_items
find_struct_impl πŸ”’
find_struct_impl looks for impl of a struct, but this also has additional feature where it takes a list of function names and check if they exist inside impl_, if even one match is found, it returns None.
generate_impl πŸ”’
generate_impl_inner πŸ”’
generate_impl_with_item πŸ”’
Generates the corresponding impl Type {} including type and lifetime parameters.
generate_trait_impl πŸ”’
Generates the corresponding impl <trait> for Type {} including type and lifetime parameters, with <trait> appended to implβ€˜s generic parameters’ bounds.
generate_trait_impl_intransitive πŸ”’
Generates the corresponding impl <trait> for Type {} including type and lifetime parameters, with implβ€˜s generic parameters’ bounds kept as-is.
generate_trait_impl_intransitive_with_item πŸ”’
generate_trait_impl_with_item πŸ”’
generic_param_associated_bounds πŸ”’
get_methods πŸ”’
handle_as_ref_slice πŸ”’
handle_as_ref_str πŸ”’
handle_copy πŸ”’
handle_dereferenced πŸ”’
handle_option_as_ref πŸ”’
handle_result_as_ref πŸ”’
has_any_fn πŸ”’
has_test_related_attribute
insert_attributes πŸ”’
invert_boolean_expression πŸ”’
invert_special_case πŸ”’
is_body_const
is_never_block πŸ”’
is_selected πŸ”’
needs_parens_in_call πŸ”’
next_prev πŸ”’
replace_record_field_expr πŸ”’
Replaces the record expression, handling field shorthands including inside macros.
required_hashes πŸ”’
Calculate the number of hashes required for a raw string containing s
string_prefix πŸ”’
Calculate the string literal prefix length
string_suffix πŸ”’
Calculate the string literal suffix length
test_related_attribute_syn
This is a method with a heuristics to support test methods annotated with custom test annotations, such as #[test_case(...)], #[tokio::test] and similar. Also a regular #[test] annotation is supported.
trimmed_text_range πŸ”’
Trim(remove leading and trailing whitespace) initial_range in source_file, return the trimmed range.
tt_from_syntax πŸ”’
Creates a token tree list from a syntax node, creating the needed delimited sub token trees. Assumes that the input syntax node is a valid syntax tree.
unwrap_trivial_block πŸ”’
vis_offset πŸ”’
wrap_block πŸ”’
wrap_paren πŸ”’
wrap_paren_in_call πŸ”’