Trait biome_formatter::FormatRule
source · pub trait FormatRule<T> {
type Context;
// Required method
fn fmt(
&self,
item: &T,
f: &mut Formatter<'_, Self::Context>
) -> FormatResult<()>;
}
Expand description
Rule that knows how to format an object of type T
.
Implementing Format on the object itself is preferred over implementing FormatRule but this isn’t possible inside of a dependent crate for external type.
For example, the biome_js_formatter
crate isn’t able to implement Format on JsIfStatement
because both the Format trait and JsIfStatement
are external types (Rust’s orphan rule).
That’s why the biome_js_formatter
crate must define a new-type that implements the formatting
of JsIfStatement
.