## PrintAttribute

# Trait PrintAttribute

Source

    pub trait PrintAttribute {
        // Required methods
        fn should_render(&self) -> bool;
        fn print_attribute(&self, p: &mut Printer);
    }

Expand description

This trait is used to print attributes in `rustc_hir_pretty`.

For structs and enums it can be derived using `rustc_macros::PrintAttribute`. The output will look a lot like a `Debug` implementation, but fields of several types like `Span`s and empty tuples, are gracefully skipped so they don’t clutter the representation much.

## Required Methods§

Source

#### fn should_render(&self) -> bool

Whether or not this will render as something meaningful, or if it’s skipped (which will force the containing struct to also skip printing a comma and the field name).

Source

#### fn print_attribute(&self, p: &mut Printer)

## Implementations on Foreign Types§

Source§

### impl PrintAttribute for CommentKind

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for IntTy

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for UintTy

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Transparency

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for bool

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u16

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u128

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for ()

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for Align

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Span

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for ErrorGuaranteed

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for Ident

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Symbol

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for NonZero<u32>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<A: PrintAttribute, B: PrintAttribute, C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (A, B, C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<B: PrintAttribute, C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (B, C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<G: PrintAttribute, H: PrintAttribute> PrintAttribute for (G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<H: PrintAttribute> PrintAttribute for (H,)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for Option<T>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for &T

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for ThinVec<T>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

## Implementors§

Source§

### impl PrintAttribute for StabilityLevel

Source§

### impl PrintAttribute for StableSince

Source§

### impl PrintAttribute for UnstableReason

Source§

### impl PrintAttribute for AttrStyle

Source§

### impl PrintAttribute for AttributeKind

Source§

### impl PrintAttribute for CfgEntry

Source§

### impl PrintAttribute for CoverageAttrKind

Source§

### impl PrintAttribute for DebuggerVisualizerType

Source§

### impl PrintAttribute for DeprecatedSince

Source§

### impl PrintAttribute for InlineAttr

Source§

### impl PrintAttribute for IntType

Source§

### impl PrintAttribute for Linkage

Source§

### impl PrintAttribute for MacroUseArgs

Source§

### impl PrintAttribute for MirDialect

Source§

### impl PrintAttribute for MirPhase

Source§

### impl PrintAttribute for NativeLibKind

Source§

### impl PrintAttribute for OptimizeAttr

Source§

### impl PrintAttribute for PeImportNameType

Source§

### impl PrintAttribute for ReprAttr

Source§

### impl PrintAttribute for UsedBy

Source§

### impl PrintAttribute for Limit

Source§

### impl PrintAttribute for ConstStability

Source§

### impl PrintAttribute for DefaultBodyStability

Source§

### impl PrintAttribute for PartialConstStability

Source§

### impl PrintAttribute for RustcVersion

Source§

### impl PrintAttribute for Stability

Source§

### impl PrintAttribute for DebugVisualizer

Source§

### impl PrintAttribute for Deprecation

Source§

### impl PrintAttribute for LinkEntry

Source§

### impl PrintAttribute for SanitizerSet