Skip to content

Commit

Permalink
Fix clippy::needless_lifetimes warning (#113)
Browse files Browse the repository at this point in the history
```
warning: the following explicit lifetimes could be elided: 'a
  --> async-stream/src/yielder.rs:90:6
   |
90 | impl<'a, T> Drop for Enter<'a, T> {
   |      ^^                    ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
   = note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
   |
90 - impl<'a, T> Drop for Enter<'a, T> {
90 + impl<T> Drop for Enter<'_, T> {
   |

warning: the following explicit lifetimes could be elided: 'a
   --> async-stream/tests/stream.rs:164:19
    |
164 |         fn stream<'a>(&'a self) -> impl Stream<Item = &str> + 'a {
    |                   ^^   ^^                              ^      ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
    = note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
    |
164 -         fn stream<'a>(&'a self) -> impl Stream<Item = &str> + 'a {
164 +         fn stream(&self) -> impl Stream<Item = &str> + '_ {
    |
```
  • Loading branch information
taiki-e authored Dec 8, 2024
1 parent b0b2f22 commit 7f9ef66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion async-stream/src/yielder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T> Receiver<T> {

// ===== impl Enter =====

impl<'a, T> Drop for Enter<'a, T> {
impl<T> Drop for Enter<'_, T> {
fn drop(&mut self) {
STORE.with(|cell| cell.set(self.prev));
}
Expand Down
2 changes: 1 addition & 1 deletion async-stream/tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async fn borrow_self() {
struct Data(String);

impl Data {
fn stream<'a>(&'a self) -> impl Stream<Item = &str> + 'a {
fn stream(&self) -> impl Stream<Item = &str> + '_ {
stream! {
yield &self.0[..];
}
Expand Down

0 comments on commit 7f9ef66

Please sign in to comment.