playground: Add AST/Tokens/Formatter panels (#5859)

This commit is contained in:
Micha Reiser 2023-07-19 16:46:08 +02:00 committed by GitHub
parent 9ed7ceeb0a
commit 46a17d11f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1343 additions and 780 deletions

View file

@ -38,7 +38,7 @@ mod source_code;
use crate::formatter::Formatter;
use crate::group_id::UniqueGroupIdBuilder;
use crate::prelude::TagKind;
use std::fmt::Debug;
use std::fmt::{Debug, Display};
use std::marker::PhantomData;
use crate::format_element::document::Document;
@ -331,6 +331,16 @@ where
Ok(printed)
}
}
impl<Context> Display for Formatted<Context>
where
Context: FormatContext,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.document.display(self.context.source_code()), f)
}
}
pub type PrintResult<T> = Result<T, PrintError>;
#[derive(Debug, Clone, Eq, PartialEq)]