Enum clippy_lints::utils::sugg::Sugg
[−]
[src]
pub enum Sugg<'a> { NonParen(Cow<'a, str>), MaybeParen(Cow<'a, str>), BinOp(AssocOp, Cow<'a, str>), }
A helper type to build suggestion correctly handling parenthesis.
Variants
NonParen(Cow<'a, str>)
An expression that never needs parenthesis such as 1337
or [0; 42]
.
MaybeParen(Cow<'a, str>)
An expression that does not fit in other variants.
BinOp(AssocOp, Cow<'a, str>)
A binary operator expression, including as
-casts and explicit type coercion.
Methods
impl<'a> Sugg<'a>
[src]
fn hir_opt(cx: &LateContext, expr: &Expr) -> Option<Sugg<'a>>
Prepare a suggestion from an expression.
fn hir(cx: &LateContext, expr: &Expr, default: &'a str) -> Sugg<'a>
Convenience function around hir_opt
for suggestions with a default text.
fn ast(cx: &EarlyContext, expr: &Expr, default: &'a str) -> Sugg<'a>
Prepare a suggestion from an expression.
fn and(self, rhs: Self) -> Sugg<'static>
Convenience method to create the <lhs> && <rhs>
suggestion.
fn as_ty<R: Display>(self, rhs: R) -> Sugg<'static>
Convenience method to create the <lhs> as <rhs>
suggestion.
fn addr(self) -> Sugg<'static>
Convenience method to create the &<expr>
suggestion.
fn mut_addr(self) -> Sugg<'static>
Convenience method to create the &mut <expr>
suggestion.
fn deref(self) -> Sugg<'static>
Convenience method to create the *<expr>
suggestion.
fn range(self, end: Self, limit: RangeLimits) -> Sugg<'static>
Convenience method to create the <lhs>..<rhs>
or <lhs>...<rhs>
suggestion.
fn maybe_par(self) -> Self
Add parenthesis to any expression that might need them. Suitable to the self
argument of
a method call (eg. to build bar.foo()
or (1 + 2).foo()
).
Trait Implementations
impl<'a> Display for Sugg<'a>
[src]
impl<'a, 'b> Add<Sugg<'b>> for Sugg<'a>
[src]
type Output = Sugg<'static>
The resulting type after applying the +
operator
fn add(self, rhs: Sugg<'b>) -> Sugg<'static>
The method for the +
operator
impl<'a, 'b> Sub<Sugg<'b>> for Sugg<'a>
[src]
type Output = Sugg<'static>
The resulting type after applying the -
operator
fn sub(self, rhs: Sugg<'b>) -> Sugg<'static>
The method for the -
operator