Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply clippy fixes #1090

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
More clipy fixes
jayvdb committed Jan 23, 2025
commit c8b9a484025e9e4cbb489a48b2b2b964c514a24a
6 changes: 3 additions & 3 deletions src/path/path.rs
Original file line number Diff line number Diff line change
@@ -1015,9 +1015,9 @@ impl<'a> From<&'a std::path::Path> for &'a Path {
}
}

impl<'a> Into<&'a std::path::Path> for &'a Path {
fn into(self) -> &'a std::path::Path {
std::path::Path::new(&self.inner)
impl<'a> From<&'a Path> for &'a std::path::Path {
fn from(val: &'a Path) -> Self {
std::path::Path::new(&val.inner)
}
}

6 changes: 3 additions & 3 deletions src/path/pathbuf.rs
Original file line number Diff line number Diff line change
@@ -364,9 +364,9 @@ impl From<std::path::PathBuf> for PathBuf {
}
}

impl Into<std::path::PathBuf> for PathBuf {
fn into(self) -> std::path::PathBuf {
self.inner
impl From<PathBuf> for std::path::PathBuf {
fn from(val: PathBuf) -> Self {
val.inner
}
}

2 changes: 1 addition & 1 deletion src/stream/stream/find.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ impl<'a, S, P> FindFuture<'a, S, P> {

impl<S: Unpin, P> Unpin for FindFuture<'_, S, P> {}

impl<'a, S, P> Future for FindFuture<'a, S, P>
impl<S, P> Future for FindFuture<'_, S, P>
where
S: Stream + Unpin + Sized,
P: FnMut(&S::Item) -> bool,
2 changes: 1 addition & 1 deletion src/stream/stream/find_map.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ impl<'a, S, F> FindMapFuture<'a, S, F> {

impl<S: Unpin, F> Unpin for FindMapFuture<'_, S, F> {}

impl<'a, S, B, F> Future for FindMapFuture<'a, S, F>
impl<S, B, F> Future for FindMapFuture<'_, S, F>
where
S: Stream + Unpin + Sized,
F: FnMut(S::Item) -> Option<B>,
2 changes: 1 addition & 1 deletion src/stream/stream/nth.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ impl<'a, S> NthFuture<'a, S> {
}
}

impl<'a, S> Future for NthFuture<'a, S>
impl<S> Future for NthFuture<'_, S>
where
S: Stream + Unpin + Sized,
{
4 changes: 2 additions & 2 deletions src/stream/stream/position.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ pub struct PositionFuture<'a, S, P> {
index: usize,
}

impl<'a, S, P> Unpin for PositionFuture<'a, S, P> {}
impl<S, P> Unpin for PositionFuture<'_, S, P> {}

impl<'a, S, P> PositionFuture<'a, S, P> {
pub(super) fn new(stream: &'a mut S, predicate: P) -> Self {
@@ -24,7 +24,7 @@ impl<'a, S, P> PositionFuture<'a, S, P> {
}
}

impl<'a, S, P> Future for PositionFuture<'a, S, P>
impl<S, P> Future for PositionFuture<'_, S, P>
where
S: Stream + Unpin,
P: FnMut(S::Item) -> bool,
4 changes: 2 additions & 2 deletions src/stream/stream/try_fold.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ pub struct TryFoldFuture<'a, S, F, T> {
acc: Option<T>,
}

impl<'a, S, F, T> Unpin for TryFoldFuture<'a, S, F, T> {}
impl<S, F, T> Unpin for TryFoldFuture<'_, S, F, T> {}

impl<'a, S, F, T> TryFoldFuture<'a, S, F, T> {
pub(super) fn new(stream: &'a mut S, init: T, f: F) -> Self {
@@ -24,7 +24,7 @@ impl<'a, S, F, T> TryFoldFuture<'a, S, F, T> {
}
}

impl<'a, S, F, T, E> Future for TryFoldFuture<'a, S, F, T>
impl<S, F, T, E> Future for TryFoldFuture<'_, S, F, T>
where
S: Stream + Unpin,
F: FnMut(T, S::Item) -> Result<T, E>,
4 changes: 2 additions & 2 deletions src/stream/stream/try_for_each.rs
Original file line number Diff line number Diff line change
@@ -11,15 +11,15 @@ pub struct TryForEachFuture<'a, S, F> {
f: F,
}

impl<'a, S, F> Unpin for TryForEachFuture<'a, S, F> {}
impl<S, F> Unpin for TryForEachFuture<'_, S, F> {}

impl<'a, S, F> TryForEachFuture<'a, S, F> {
pub(crate) fn new(stream: &'a mut S, f: F) -> Self {
Self { stream, f }
}
}

impl<'a, S, F, E> Future for TryForEachFuture<'a, S, F>
impl<S, F, E> Future for TryForEachFuture<'_, S, F>
where
S: Stream + Unpin,
F: FnMut(S::Item) -> Result<(), E>,
32 changes: 16 additions & 16 deletions tests/channel.rs
Original file line number Diff line number Diff line change
@@ -59,38 +59,38 @@ fn len_empty_full() {
let (s, r) = channel(2);

assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), false);
assert!(s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());

s.send(()).await.unwrap();

assert_eq!(s.len(), 1);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), false);
assert!(!s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), false);
assert!(!r.is_empty());
assert!(!r.is_full());

s.send(()).await.unwrap();

assert_eq!(s.len(), 2);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), true);
assert!(!s.is_empty());
assert!(s.is_full());
assert_eq!(r.len(), 2);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), true);
assert!(!r.is_empty());
assert!(r.is_full());

let _ = r.recv().await;

assert_eq!(s.len(), 1);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), false);
assert!(!s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), false);
assert!(!r.is_empty());
assert!(!r.is_full());
})
}


Unchanged files with check annotations Beta

/// # async_std::task::block_on(async {
/// #
/// impl ExactSizeStream for Counter {
/// // We can easily calculate the remaining number of iterations.

Check failure on line 65 in src/stream/exact_size_stream.rs

GitHub Actions / Build and test (macOS-latest, beta)

non-local `impl` definition, `impl` blocks should be written at the same level as their item
/// fn len(&self) -> usize {
/// 5 - self.count
/// }
//! B = 4;
//! A = A + B;
//! C = B;
//! println!("{} {} {}", A, B, C);

Check failure on line 29 in src/sync/mod.rs

GitHub Actions / Build and test (macOS-latest, beta)

creating a shared reference to mutable static is discouraged

Check failure on line 29 in src/sync/mod.rs

GitHub Actions / Build and test (macOS-latest, beta)

creating a shared reference to mutable static is discouraged

Check failure on line 29 in src/sync/mod.rs

GitHub Actions / Build and test (macOS-latest, beta)

creating a shared reference to mutable static is discouraged
//! C = A;
//! }
//! }