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:
Dhruv Manilawala
2023-12-13 00:31:20 -06:00
committed by GitHub
parent cb99815c3e
commit 18452cf477
13 changed files with 121 additions and 65 deletions

View File

@@ -2742,7 +2742,7 @@ impl AstNode for ast::ExprFString {
{
let ast::ExprFString { value, range: _ } = self;
for f_string_part in value.parts() {
for f_string_part in value {
match f_string_part {
ast::FStringPart::Literal(string_literal) => {
visitor.visit_string_literal(string_literal);
@@ -2788,7 +2788,7 @@ impl AstNode for ast::ExprStringLiteral {
{
let ast::ExprStringLiteral { value, range: _ } = self;
for string_literal in value.parts() {
for string_literal in value {
visitor.visit_string_literal(string_literal);
}
}
@@ -2827,7 +2827,7 @@ impl AstNode for ast::ExprBytesLiteral {
{
let ast::ExprBytesLiteral { value, range: _ } = self;
for bytes_literal in value.parts() {
for bytes_literal in value {
visitor.visit_bytes_literal(bytes_literal);
}
}