Skip to content

Commit

Permalink
[Clippy] Use .is_empty() instead of comparison with 0/empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJuliusMartinez committed Feb 9, 2022
1 parent 0a208b4 commit 2f635c3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl App {
let search_term = self.screen_writer.get_command("/").unwrap();

// In vim, /<CR> is a longcut for repeating the previous search.
if search_term == "" {
if search_term.is_empty() {
let count = self.parse_input_buffer_as_number();
jumped_to_search_match = true;
self.jump_to_next_search_match(count)
Expand All @@ -260,7 +260,7 @@ impl App {
let search_term = self.screen_writer.get_command("?").unwrap();

// In vim, /<CR> is a longcut for repeating the previous search.
if search_term == "" {
if search_term.is_empty() {
let count = self.parse_input_buffer_as_number();
jumped_to_search_match = true;
self.jump_to_prev_search_match(count)
Expand Down
4 changes: 2 additions & 2 deletions src/flatjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ fn flatten_json(serde_value: SerdeValue, flat_json: &mut Vec<Row>, parents: &mut
..row
}),
SerdeValue::Array(vs) => {
if vs.len() == 0 {
if vs.is_empty() {
flat_json.push(Row {
value: Value::EmptyArray,
..row
Expand Down Expand Up @@ -522,7 +522,7 @@ fn flatten_json(serde_value: SerdeValue, flat_json: &mut Vec<Row>, parents: &mut
}
}
SerdeValue::Object(obj) => {
if obj.len() == 0 {
if obj.is_empty() {
flat_json.push(Row {
value: Value::EmptyObject,
..row
Expand Down
2 changes: 1 addition & 1 deletion src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl SearchState {
}

pub fn any_matches(&self) -> bool {
self.matches.len() > 0
!self.matches.is_empty()
}

pub fn no_matches_message(&self) -> String {
Expand Down
4 changes: 2 additions & 2 deletions src/truncatedstrview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TruncatedStrView {
/// this function, when called on the string the TruncatedStrView is
/// associated with, returns true.
pub fn can_str_fit_at_all(s: &str, available_space: isize) -> bool {
available_space > 0 || (available_space == 0 && s.len() == 0)
available_space > 0 || (available_space == 0 && s.is_empty())
}

/// Create a truncated view of a string that shows the beginning of
Expand Down Expand Up @@ -664,7 +664,7 @@ impl<'a> RangeAdjuster<'a> {
// But we have room to showing something...
self.available_space > 1 &&
// And there's something to show.
self.s.len() > 0;
!self.s.is_empty();

let mut used_space = self.used_space;
if showing_replacement_character {
Expand Down

0 comments on commit 2f635c3

Please sign in to comment.