Skip to content

Commit

Permalink
Fix clippy::unnecessary_cast warning
Browse files Browse the repository at this point in the history
```
warning: casting to the same type is unnecessary (`usize` -> `usize`)
  --> futures-util/src/stream/stream/take.rs:57:37
   |
57 |         let lower = cmp::min(lower, self.remaining as usize);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.remaining`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
   = note: `#[warn(clippy::unnecessary_cast)]` on by default

warning: casting to the same type is unnecessary (`usize` -> `usize`)
  --> futures-util/src/stream/stream/take.rs:60:28
   |
60 |             Some(x) if x < self.remaining as usize => Some(x),
   |                            ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.remaining`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`usize` -> `usize`)
  --> futures-util/src/stream/stream/take.rs:61:23
   |
61 |             _ => Some(self.remaining as usize),
   |                       ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.remaining`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
```
  • Loading branch information
taiki-e committed Oct 20, 2022
1 parent 485875f commit 5364e6c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions futures-util/src/stream/stream/take.rs
Expand Up @@ -54,11 +54,11 @@ where

let (lower, upper) = self.stream.size_hint();

let lower = cmp::min(lower, self.remaining as usize);
let lower = cmp::min(lower, self.remaining);

let upper = match upper {
Some(x) if x < self.remaining as usize => Some(x),
_ => Some(self.remaining as usize),
Some(x) if x < self.remaining => Some(x),
_ => Some(self.remaining),
};

(lower, upper)
Expand Down

0 comments on commit 5364e6c

Please sign in to comment.