RS.CLIPPY.REDUNDANT_AS_STR

`as_str` used to call a method on `str` that is also available on `String`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: redundant_as_str. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for usage of as_str() on a String chained with a method available on the String itself.

Why is this bad?

The as_str() conversion is pointless and can be removed for simplicity and cleanliness.

Example

let owned_string = "This is a string".to_owned();
owned_string.as_str().as_bytes()

Use instead:

let owned_string = "This is a string".to_owned();
owned_string.as_bytes()