Module clippy_utils::source
source Β· Expand description
Utils for extracting, inspecting or transforming source code
Structs§
- Handle to a range of text in a source file.
Traits§
- Conversion of a value into a
Span
- Conversion of a value into the range portion of a
Span
.
Functions§
- Expand a span to include a preceding comma
- Like
snippet_block
, but add braces if the expr is not anExprKind::Block
. - Returns a new Span that extends the original Span to the first non-whitespace char of the first line.
- get_
source_ πrange - Returns the indentation of the line of a span
- line_
span πExtends the span to the beginning of the spans line, incl. whitespaces. - map_
range π - Returns the position just before rarrow
- Reindent a multiline string with possibility of ignoring the first line.
- Converts a span to a code snippet if available, otherwise returns the default.
- Converts a span (from a block) to a code snippet if available, otherwise use default.
- Same as
snippet_block
, but adapts the applicability level by the rules ofsnippet_with_applicability
. - Gets a snippet of the indentation of the line of a span
- Converts a span to a code snippet. Returns
None
if not available. - Same as
snippet
, but it adapts the applicability level by following rules: - Same as
snippet_with_applicability
, but first walks the span up to the given context. - Converts
expr
to achar
literal if itβs astr
literal containing a single character (or a single byte withascii_only
) - Trims the whitespace from the start and the end of the span.
- trim_
start π - Walks the span up to the target context, thereby returning the macro call site if the span is inside a macro expansion, or the original span if it is not.
- with_
source_ πtext - Removes block comments from the given
Vec
of lines.