mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:58 +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
|
@ -6,8 +6,8 @@ use bitflags::bitflags;
|
|||
use rustc_hash::FxHashSet;
|
||||
|
||||
use ruff_python_ast::{
|
||||
self as ast, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FStringElement, IpyEscapeKind,
|
||||
Number, Operator, UnaryOp,
|
||||
self as ast, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FStringElement, FStringElements,
|
||||
IpyEscapeKind, Number, Operator, UnaryOp,
|
||||
};
|
||||
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
|
||||
|
||||
|
@ -1297,8 +1297,8 @@ impl<'src> Parser<'src> {
|
|||
/// # Panics
|
||||
///
|
||||
/// If the parser isn't positioned at a `{` or `FStringMiddle` token.
|
||||
fn parse_fstring_elements(&mut self) -> Vec<FStringElement> {
|
||||
let mut elements = vec![];
|
||||
fn parse_fstring_elements(&mut self) -> FStringElements {
|
||||
let mut elements = FStringElements::default();
|
||||
|
||||
self.parse_list(RecoveryContextKind::FStringElements, |parser| {
|
||||
let element = match parser.current_token_kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue