Function clippy_utils::source::snippet[−][src]

pub fn snippet<'a, T: LintContext>(
    cx: &T,
    span: Span,
    default: &'a str
) -> Cow<'a, str>
Expand description

Converts a span to a code snippet if available, otherwise use default.

This is useful if you want to provide suggestions for your lint or more generally, if you want to convert a given Span to a str.

Example

ⓘ
snippet(cx, expr.span, "..")