mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
Reformat redundant_as_str ui test
This commit is contained in:
parent
5224853434
commit
17d174d113
@ -1,9 +1,9 @@
|
|||||||
#![warn(clippy::redundant_as_str)]
|
#![warn(clippy::redundant_as_str)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let string = "Hello, world!".to_owned();
|
let string = "Hello, world!".to_owned();
|
||||||
|
|
||||||
// These methods are redundant and the `as_str` can be removed
|
// These methods are redundant and the `as_str` can be removed
|
||||||
let _redundant = string.as_str().as_bytes();
|
let _redundant = string.as_str().as_bytes();
|
||||||
let _redundant = string.as_str().is_empty();
|
let _redundant = string.as_str().is_empty();
|
||||||
|
|
||||||
@ -11,14 +11,14 @@ fn main() {
|
|||||||
let _no_as_str = string.as_bytes();
|
let _no_as_str = string.as_bytes();
|
||||||
let _no_as_str = string.is_empty();
|
let _no_as_str = string.is_empty();
|
||||||
|
|
||||||
// These methods are not redundant, and are equivelant to
|
// These methods are not redundant, and are equivelant to
|
||||||
// doing dereferencing the string and applying the method
|
// doing dereferencing the string and applying the method
|
||||||
let _not_redundant = string.as_str().escape_unicode();
|
let _not_redundant = string.as_str().escape_unicode();
|
||||||
let _not_redundant = string.as_str().trim();
|
let _not_redundant = string.as_str().trim();
|
||||||
let _not_redundant = string.as_str().split_whitespace();
|
let _not_redundant = string.as_str().split_whitespace();
|
||||||
|
|
||||||
// These methods don't use `as_str` and are applied on a `str` directly
|
// These methods don't use `as_str` and are applied on a `str` directly
|
||||||
let borrowed_str = "Hello, world!";
|
let borrowed_str = "Hello, world!";
|
||||||
let _is_str = borrowed_str.as_bytes();
|
let _is_str = borrowed_str.as_bytes();
|
||||||
let _is_str = borrowed_str.is_empty();
|
let _is_str = borrowed_str.is_empty();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user