Introduce Token element (#7048)

This commit is contained in:
Micha Reiser 2023-09-02 10:05:47 +02:00 committed by GitHub
parent 2f3a950f6f
commit c05e4628b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 733 additions and 723 deletions

View file

@ -70,7 +70,7 @@ impl<'fmt, Context> Argument<'fmt, Context> {
///
/// # fn main() -> FormatResult<()> {
/// let formatted = format!(SimpleFormatContext::default(), [
/// format_args!(text("a"), space(), text("b"))
/// format_args!(token("a"), space(), token("b"))
/// ])?;
///
/// assert_eq!("a b", formatted.print()?.as_code());
@ -135,11 +135,11 @@ mod tests {
write!(
&mut buffer,
[
text("function"),
token("function"),
space(),
text("a"),
token("a"),
space(),
group(&format_args!(text("("), text(")")))
group(&format_args!(token("("), token(")")))
]
)
.unwrap();
@ -147,14 +147,14 @@ mod tests {
assert_eq!(
buffer.into_vec(),
vec![
FormatElement::StaticText { text: "function" },
FormatElement::Token { text: "function" },
FormatElement::Space,
FormatElement::StaticText { text: "a" },
FormatElement::Token { text: "a" },
FormatElement::Space,
// Group
FormatElement::Tag(Tag::StartGroup(tag::Group::new())),
FormatElement::StaticText { text: "(" },
FormatElement::StaticText { text: ")" },
FormatElement::Token { text: "(" },
FormatElement::Token { text: ")" },
FormatElement::Tag(Tag::EndGroup)
]
);