Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Document macros, store owned content in builders, implement Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Jun 1, 2022
1 parent b8db001 commit ce4c4d1
Show file tree
Hide file tree
Showing 69 changed files with 724 additions and 787 deletions.
19 changes: 14 additions & 5 deletions crates/rome_formatter/src/arguments.rs
@@ -1,5 +1,5 @@
use super::{Buffer, Format, Formatter};
use crate::FormatResult;
use crate::{FormatOptions, FormatResult, Formatted};
use std::ffi::c_void;
use std::marker::PhantomData;

Expand Down Expand Up @@ -97,16 +97,25 @@ impl<O> Format<O> for Arguments<'_, O> {
}
}

impl<Context> std::fmt::Debug for Arguments<'_, Context>
where
Context: Default + FormatOptions,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match crate::format!(Context::default(), [self]) {
Ok(formatted) => Formatted::fmt(&formatted, f),
Err(err) => std::write!(f, "Err({err})"),
}
}
}

#[cfg(test)]
mod tests {
use crate::prelude::*;
use crate::{format_args, write, FormatState, VecBuffer};

#[test]
fn test_nesting() {
std::format_args!("test {}", "a");
// Format_arguments not very useful, but I guess the same as normal format_args

let mut context = FormatState::new(());
let mut buffer = VecBuffer::new(&mut context);

Expand All @@ -117,7 +126,7 @@ mod tests {
space_token(),
token("a"),
space_token(),
group_elements(&format_args!(token("("), token(")")))
group_elements(format_args!(token("("), token(")")))
]
)
.unwrap();
Expand Down

0 comments on commit ce4c4d1

Please sign in to comment.