Skip to main content

format_tokens

Function format_tokens 

Source
pub fn format_tokens(tokens: &TokenStream) -> String
Expand description

Formats a token stream using rustfmt.

Returns the formatted code as a string. If rustfmt is not available or fails, returns the unformatted token stream as a string.

ยงExample

use quote::quote;
use clifford_codegen::codegen::format_tokens;

let tokens = quote! {
    pub struct Foo { x: i32 }
};

let formatted = format_tokens(&tokens);
// formatted will be properly indented and spaced