mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 15:48:22 +00:00
Implement IntoIterator
for FStringElements
(#11410)
A change which I lost somewhere when I force pushed in https://github.com/astral-sh/ruff/pull/11400
This commit is contained in:
parent
ca99e9e2f0
commit
c3c87e86ef
5 changed files with 26 additions and 8 deletions
|
@ -87,7 +87,7 @@ pub(crate) fn invalid_escape_sequence(checker: &mut Checker, string_like: String
|
||||||
}
|
}
|
||||||
StringLikePart::FString(f_string) => {
|
StringLikePart::FString(f_string) => {
|
||||||
let flags = AnyStringFlags::from(f_string.flags);
|
let flags = AnyStringFlags::from(f_string.flags);
|
||||||
for element in f_string.elements.iter() {
|
for element in &f_string.elements {
|
||||||
match element {
|
match element {
|
||||||
FStringElement::Literal(literal) => {
|
FStringElement::Literal(literal) => {
|
||||||
check(
|
check(
|
||||||
|
|
|
@ -2814,7 +2814,7 @@ impl AstNode for ast::FStringFormatSpec {
|
||||||
where
|
where
|
||||||
V: PreorderVisitor<'a> + ?Sized,
|
V: PreorderVisitor<'a> + ?Sized,
|
||||||
{
|
{
|
||||||
for element in self.elements.iter() {
|
for element in &self.elements {
|
||||||
visitor.visit_f_string_element(element);
|
visitor.visit_f_string_element(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2864,7 +2864,7 @@ impl AstNode for ast::FStringExpressionElement {
|
||||||
visitor.visit_expr(expression);
|
visitor.visit_expr(expression);
|
||||||
|
|
||||||
if let Some(format_spec) = format_spec {
|
if let Some(format_spec) = format_spec {
|
||||||
for spec_part in format_spec.elements.iter() {
|
for spec_part in &format_spec.elements {
|
||||||
visitor.visit_f_string_element(spec_part);
|
visitor.visit_f_string_element(spec_part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4800,7 +4800,7 @@ impl AstNode for ast::FString {
|
||||||
flags: _,
|
flags: _,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
for fstring_element in elements.iter() {
|
for fstring_element in elements {
|
||||||
visitor.visit_f_string_element(fstring_element);
|
visitor.visit_f_string_element(fstring_element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1526,6 +1526,24 @@ impl From<Vec<FStringElement>> for FStringElements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> IntoIterator for &'a FStringElements {
|
||||||
|
type IntoIter = Iter<'a, FStringElement>;
|
||||||
|
type Item = &'a FStringElement;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.iter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> IntoIterator for &'a mut FStringElements {
|
||||||
|
type IntoIter = IterMut<'a, FStringElement>;
|
||||||
|
type Item = &'a mut FStringElement;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.iter_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deref for FStringElements {
|
impl Deref for FStringElements {
|
||||||
type Target = Vec<FStringElement>;
|
type Target = Vec<FStringElement>;
|
||||||
|
|
||||||
|
|
|
@ -739,7 +739,7 @@ pub fn walk_pattern_keyword<'a, V: Visitor<'a> + ?Sized>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_f_string<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, f_string: &'a FString) {
|
pub fn walk_f_string<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, f_string: &'a FString) {
|
||||||
for f_string_element in f_string.elements.iter() {
|
for f_string_element in &f_string.elements {
|
||||||
visitor.visit_f_string_element(f_string_element);
|
visitor.visit_f_string_element(f_string_element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ pub fn walk_f_string_element<'a, V: Visitor<'a> + ?Sized>(
|
||||||
{
|
{
|
||||||
visitor.visit_expr(expression);
|
visitor.visit_expr(expression);
|
||||||
if let Some(format_spec) = format_spec {
|
if let Some(format_spec) = format_spec {
|
||||||
for spec_element in format_spec.elements.iter() {
|
for spec_element in &format_spec.elements {
|
||||||
visitor.visit_f_string_element(spec_element);
|
visitor.visit_f_string_element(spec_element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,7 +746,7 @@ pub fn walk_pattern_keyword<V: Transformer + ?Sized>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_f_string<V: Transformer + ?Sized>(visitor: &V, f_string: &mut FString) {
|
pub fn walk_f_string<V: Transformer + ?Sized>(visitor: &V, f_string: &mut FString) {
|
||||||
for element in f_string.elements.iter_mut() {
|
for element in &mut f_string.elements {
|
||||||
visitor.visit_f_string_element(element);
|
visitor.visit_f_string_element(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ pub fn walk_f_string_element<V: Transformer + ?Sized>(
|
||||||
{
|
{
|
||||||
visitor.visit_expr(expression);
|
visitor.visit_expr(expression);
|
||||||
if let Some(format_spec) = format_spec {
|
if let Some(format_spec) = format_spec {
|
||||||
for spec_element in format_spec.elements.iter_mut() {
|
for spec_element in &mut format_spec.elements {
|
||||||
visitor.visit_f_string_element(spec_element);
|
visitor.visit_f_string_element(spec_element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue