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:
@@ -86,13 +86,13 @@ impl<'a> AnyString<'a> {
|
||||
fn parts(&self) -> Vec<AnyStringPart<'a>> {
|
||||
match self {
|
||||
Self::String(ExprStringLiteral { value, .. }) => {
|
||||
value.parts().map(AnyStringPart::String).collect()
|
||||
value.iter().map(AnyStringPart::String).collect()
|
||||
}
|
||||
Self::Bytes(ExprBytesLiteral { value, .. }) => {
|
||||
value.parts().map(AnyStringPart::Bytes).collect()
|
||||
value.iter().map(AnyStringPart::Bytes).collect()
|
||||
}
|
||||
Self::FString(ExprFString { value, .. }) => value
|
||||
.parts()
|
||||
.iter()
|
||||
.map(|f_string_part| match f_string_part {
|
||||
ast::FStringPart::Literal(string_literal) => {
|
||||
AnyStringPart::String(string_literal)
|
||||
|
||||
Reference in New Issue
Block a user