Skip to content

Commit

Permalink
Fix redundant_as_str .fixed file not being consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev380 committed Sep 18, 2023
1 parent 17d174d commit d9d25e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/ui/redundant_as_str.fixed
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#![warn(clippy::redundant_as_str)]

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_bytes();
let _redundant = string.is_empty();

// These methods don't use `as_str` when they are redundant
let _no_as_str = string.as_bytes();
let _no_as_str = string.is_empty();

// These methods are not redundant, and are equivelant to
// doing dereferencing the string and applying the method
// These methods are not redundant, and are equivelant to
// doing dereferencing the string and applying the method
let _not_redundant = string.as_str().escape_unicode();
let _not_redundant = string.as_str().trim();
let _not_redundant = string.as_str().split_whitespace();

// These methods don't use `as_str` and are applied on a `str` directly
let borrowed_str = "Hello, world!";
// These methods don't use `as_str` and are applied on a `str` directly
let borrowed_str = "Hello, world!";
let _is_str = borrowed_str.as_bytes();
let _is_str = borrowed_str.is_empty();
}

0 comments on commit d9d25e9

Please sign in to comment.