Function biome_formatter::format

source ·
pub fn format<Context>(
    context: Context,
    arguments: Arguments<'_, Context>
) -> FormatResult<Formatted<Context>>
where Context: FormatContext,
Expand description

The format function takes an Arguments struct and returns the resulting formatting IR.

The Arguments instance can be created with the format_args!.

§Examples

Basic usage:

use biome_formatter::prelude::*;
use biome_formatter::{format, format_args};

let formatted = format!(SimpleFormatContext::default(), [&format_args!(text("test"))])?;
assert_eq!("test", formatted.print()?.as_code());

Please note that using format! might be preferable. Example:

use biome_formatter::prelude::*;
use biome_formatter::{format};

let formatted = format!(SimpleFormatContext::default(), [text("test")])?;
assert_eq!("test", formatted.print()?.as_code());