Use sugg::Sugg in transmute links
This commit is contained in:
@@ -30,6 +30,7 @@ impl<'a> std::fmt::Display for Sugg<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method
|
||||
impl<'a> Sugg<'a> {
|
||||
pub fn hir_opt(cx: &LateContext, expr: &hir::Expr) -> Option<Sugg<'a>> {
|
||||
snippet_opt(cx, expr.span).map(|snippet| {
|
||||
@@ -124,6 +125,11 @@ impl<'a> Sugg<'a> {
|
||||
make_binop(ast::BinOpKind::And, &self, &rhs)
|
||||
}
|
||||
|
||||
/// Convenience method to create the `<lhs> as <rhs>` suggestion.
|
||||
pub fn as_ty(self, rhs: &str) -> Sugg<'static> {
|
||||
make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.into()))
|
||||
}
|
||||
|
||||
/// Convenience method to create the `&<expr>` suggestion.
|
||||
pub fn addr(self) -> Sugg<'static> {
|
||||
make_unop("&", self)
|
||||
|
||||
Reference in New Issue
Block a user