mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-15 16:10:38 +00:00
Create a newtype wrapper around Vec<FStringElement>
(#11400)
## Summary This PR adds a newtype wrapper around `Vec<FStringElement>` that derefs to a `&Vec<FStringElement>`. Both f-string and format specifier are made up of `Vec<FStringElement>`. By creating a newtype wrapper around it, we can share the methods for both parent types.
This commit is contained in:
parent
0dc130e841
commit
4b41e4de7f
15 changed files with 71 additions and 39 deletions
|
@ -2814,7 +2814,7 @@ impl AstNode for ast::FStringFormatSpec {
|
|||
where
|
||||
V: PreorderVisitor<'a> + ?Sized,
|
||||
{
|
||||
for element in &self.elements {
|
||||
for element in self.elements.iter() {
|
||||
visitor.visit_f_string_element(element);
|
||||
}
|
||||
}
|
||||
|
@ -2864,7 +2864,7 @@ impl AstNode for ast::FStringExpressionElement {
|
|||
visitor.visit_expr(expression);
|
||||
|
||||
if let Some(format_spec) = format_spec {
|
||||
for spec_part in &format_spec.elements {
|
||||
for spec_part in format_spec.elements.iter() {
|
||||
visitor.visit_f_string_element(spec_part);
|
||||
}
|
||||
}
|
||||
|
@ -4800,7 +4800,7 @@ impl AstNode for ast::FString {
|
|||
flags: _,
|
||||
} = self;
|
||||
|
||||
for fstring_element in elements {
|
||||
for fstring_element in elements.iter() {
|
||||
visitor.visit_f_string_element(fstring_element);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue