mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Add as_slice
method for all string nodes (#9111)
This PR adds a `as_slice` method to all the string nodes which returns all the parts of the nodes as a slice. This will be useful in the next PR to split the string formatting to use this method to extract the _single node_ or _implicitly concanated nodes_.
This commit is contained in:
parent
cb99815c3e
commit
18452cf477
13 changed files with 121 additions and 65 deletions
|
@ -1077,7 +1077,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => {
|
||||
let mut first = true;
|
||||
for bytes_literal in value.parts() {
|
||||
for bytes_literal in value {
|
||||
self.p_delim(&mut first, " ");
|
||||
self.p_bytes_repr(&bytes_literal.value);
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ impl<'a> Generator<'a> {
|
|||
|
||||
fn unparse_string_literal_value(&mut self, value: &ast::StringLiteralValue) {
|
||||
let mut first = true;
|
||||
for string_literal in value.parts() {
|
||||
for string_literal in value {
|
||||
self.p_delim(&mut first, " ");
|
||||
self.unparse_string_literal(string_literal);
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ impl<'a> Generator<'a> {
|
|||
|
||||
fn unparse_f_string_value(&mut self, value: &ast::FStringValue, is_spec: bool) {
|
||||
let mut first = true;
|
||||
for f_string_part in value.parts() {
|
||||
for f_string_part in value {
|
||||
self.p_delim(&mut first, " ");
|
||||
match f_string_part {
|
||||
ast::FStringPart::Literal(string_literal) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue