Skip to main content

## Rewrite

# Trait Rewrite

Source

    pub(crate) trait Rewrite {
        // Required method
        fn rewrite(
            &self,
            context: &RewriteContext<'_>,
            shape: Shape,
        ) -> Option<String>;

        // Provided method
        fn rewrite_result(
            &self,
            context: &RewriteContext<'_>,
            shape: Shape,
        ) -> Result<String, RewriteError> { ... }
    }

## Required Methods§

Source

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Rewrite self into shape.

## Provided Methods§

Source

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

## Implementations on Foreign Types§

Source§

### impl Rewrite for AssocItemConstraintKind

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for FnRetTy

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for GenericArg

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for GenericBound

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for MetaItemInner

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for PreciseCapturingArg

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for AnonConst

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for AssocItemConstraint

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Attribute

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Block

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Expr

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for FieldDef

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for GenericParam

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Item

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Lifetime

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, _: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Local

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for MetaItem

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Param

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Pat

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for PatField

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for PolyTraitRef

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for TraitRef

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for Ty

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for TyPat

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for WherePredicate

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for ForeignItem

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for GenericBounds

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl Rewrite for [Attribute]

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

Source§

#### fn rewrite_result( &self, context: &RewriteContext<'_>, shape: Shape, ) -> Result<String, RewriteError>

Source§

### impl<T: Rewrite> Rewrite for Box<T>

Source§

#### fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>

## Implementors§

Source§

### impl Rewrite for MacroArg

Source§

### impl Rewrite for Chain

Source§

### impl Rewrite for ChainItem

Source§

### impl Rewrite for UseSegment

Source§

### impl Rewrite for UseTree

Source§

### impl<'a> Rewrite for OverflowableItem<'a>

Source§

### impl<'a> Rewrite for TuplePatField<'a>

Source§

### impl<'a> Rewrite for SegmentParam<'a>

Source§

### impl<'a> Rewrite for ControlFlow<'a>

Source§

### impl<'a> Rewrite for OpaqueType<'a>

Source§

### impl<'a> Rewrite for TraitAliasBounds<'a>

Source§

### impl<'a> Rewrite for ArmWrapper<'a>

Source§

### impl<'a> Rewrite for Stmt<'a>

Source§

### impl<'a, T: Rewrite> Rewrite for RangeOperand<'a, T>