mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00
Introduce Token element (#7048)
This commit is contained in:
parent
2f3a950f6f
commit
c05e4628b1
78 changed files with 733 additions and 723 deletions
|
@ -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)
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue