Rename as_str to to_str (#8886)

This PR renames the method on `StringLiteralValue` from `as_str` to
`to_str`. The main motivation is to follow the naming convention as
described in the [Rust API
Guidelines](https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv).
This method can perform a string allocation in case the string is
implicitly concatenated.
This commit is contained in:
Dhruv Manilawala 2023-11-28 18:50:42 -06:00 committed by GitHub
parent b28556d739
commit ec7456bac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 68 additions and 68 deletions

View file

@ -24,7 +24,7 @@ where
fn add_to_names<'a>(elts: &'a [Expr], names: &mut Vec<&'a str>, flags: &mut DunderAllFlags) {
for elt in elts {
if let Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) = elt {
names.push(value.as_str());
names.push(value.to_str());
} else {
*flags |= DunderAllFlags::INVALID_OBJECT;
}