Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Apply clippy fixes#1090

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jayvdb wants to merge2 commits intoasync-rs:main
base:main
Choose a base branch
Loading
fromjayvdb:clippy-fixes
Open
Show file tree
Hide file tree
Changes fromall commits
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
4 changes: 2 additions & 2 deletionssrc/fs/file.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -696,7 +696,7 @@ impl LockGuard<State> {
// file. This call should not block because it doesn't touch the actual file on disk.
if pos == SeekFrom::Current(0) {
// Poll the internal file cursor.
let internal = (&*self.file).seek(SeekFrom::Current(0))?;
let internal = (&*self.file).stream_position()?;

// Factor in the difference caused by caching.
let actual = match self.mode {
Expand All@@ -714,7 +714,7 @@ impl LockGuard<State> {
if let Some(new) = (start as i64).checked_add(diff) {
if 0 <= new && new <= self.cache.len() as i64 {
// Poll the internal file cursor.
let internal = (&*self.file).seek(SeekFrom::Current(0))?;
let internal = (&*self.file).stream_position()?;

// Adjust the current position in the read cache.
self.mode = Mode::Reading(new as usize);
Expand Down
2 changes: 1 addition & 1 deletionsrc/future/poll_fn.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,6 +44,6 @@ where
type Output = T;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
(&mutself.f)(cx)
(self.f)(cx)
}
}
4 changes: 2 additions & 2 deletionssrc/io/buf_read/lines.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,7 +50,7 @@ impl<R: BufRead> Stream for Lines<R> {
this.buf.pop();
}
}
Poll::Ready(Some(Ok(mem::replace(this.buf, String::new()))))
Poll::Ready(Some(Ok(mem::take(this.buf))))
}
}

Expand All@@ -62,7 +62,7 @@ pub fn read_line_internal<R: BufRead + ?Sized>(
read: &mut usize,
) -> Poll<io::Result<usize>> {
let ret = futures_core::ready!(read_until_internal(reader, cx, b'\n', bytes, read));
if str::from_utf8(&bytes).is_err() {
if str::from_utf8(bytes).is_err() {
Poll::Ready(ret.and_then(|_| {
Err(io::Error::new(
io::ErrorKind::InvalidData,
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/buf_read/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -136,7 +136,7 @@ pub trait BufReadExt: BufRead {
{
ReadLineFuture {
reader: self,
bytes: unsafe { mem::replace(buf.as_mut_vec(), Vec::new()) },
bytes: unsafe {std::mem::take(buf.as_mut_vec()) },
buf,
read: 0,
}
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/buf_read/read_line.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ impl<T: BufRead + Unpin + ?Sized> Future for ReadLineFuture<'_, T> {
let reader = Pin::new(reader);

let ret = futures_core::ready!(read_until_internal(reader, cx, b'\n', bytes, read));
if str::from_utf8(&bytes).is_err() {
if str::from_utf8(bytes).is_err() {
Poll::Ready(ret.and_then(|_| {
Err(io::Error::new(
io::ErrorKind::InvalidData,
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/buf_read/split.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,6 @@ impl<R: BufRead> Stream for Split<R> {
if this.buf[this.buf.len() - 1] == *this.delim {
this.buf.pop();
}
Poll::Ready(Some(Ok(mem::replace(this.buf, vec![]))))
Poll::Ready(Some(Ok(mem::take(this.buf))))
}
}
2 changes: 1 addition & 1 deletionsrc/io/read/chain.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,7 +144,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
let this = self.project();
if !*this.done_first {
match futures_core::ready!(this.first.poll_fill_buf(cx)) {
Ok(buf) if buf.is_empty() => {
Ok([]) => {
*this.done_first = true;
}
Ok(buf) => return Poll::Ready(Ok(buf)),
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/read/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -168,7 +168,7 @@ pub trait ReadExt: Read {
let start_len = buf.len();
ReadToStringFuture {
reader: self,
bytes: unsafe { mem::replace(buf.as_mut_vec(), Vec::new()) },
bytes: unsafe { mem::take(buf.as_mut_vec()) },
buf,
start_len,
}
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/read/read_exact.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ impl<T: Read + Unpin + ?Sized> Future for ReadExactFuture<'_, T> {

while !buf.is_empty() {
let n = futures_core::ready!(Pin::new(&mut *reader).poll_read(cx, buf))?;
let (_, rest) = mem::replace(buf, &mut []).split_at_mut(n);
let (_, rest) = mem::take(buf).split_at_mut(n);
*buf = rest;

if n == 0 {
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/read/read_to_string.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ impl<T: Read + Unpin + ?Sized> Future for ReadToStringFuture<'_, T> {
let reader = Pin::new(reader);

let ret = futures_core::ready!(read_to_end_internal(reader, cx, bytes, *start_len));
if str::from_utf8(&bytes).is_err() {
if str::from_utf8(bytes).is_err() {
Poll::Ready(ret.and_then(|_| {
Err(io::Error::new(
io::ErrorKind::InvalidData,
Expand Down
2 changes: 1 addition & 1 deletionsrc/io/write/write_all.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ impl<T: Write + Unpin + ?Sized> Future for WriteAllFuture<'_, T> {

while !buf.is_empty() {
let n = futures_core::ready!(Pin::new(&mut **writer).poll_write(cx, buf))?;
let (_, rest) = mem::replace(buf, &[]).split_at(n);
let (_, rest) = mem::take(buf).split_at(n);
*buf = rest;

if n == 0 {
Expand Down
2 changes: 1 addition & 1 deletionsrc/net/addr.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,6 +280,6 @@ impl ToSocketAddrs for String {
impl Future<Output = Self::Iter>,
ToSocketAddrsFuture<Self::Iter>
) {
(&**self).to_socket_addrs()
(**self).to_socket_addrs()
}
}
10 changes: 5 additions & 5 deletionssrc/path/path.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -261,7 +261,7 @@ impl Path {
/// assert_eq!(ancestors.next(), None);
/// ```
pub fn ancestors(&self) -> Ancestors<'_> {
Ancestors { next: Some(&self) }
Ancestors { next: Some(self) }
}

/// Returns the final component of the `Path`, if there is one.
Expand DownExpand Up@@ -1011,13 +1011,13 @@ impl_cmp_os_str!(&'a Path, OsString);

impl<'a> From<&'a std::path::Path> for &'a Path {
fn from(path: &'a std::path::Path) -> &'a Path {
&Path::new(path.as_os_str())
Path::new(path.as_os_str())
}
}

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

Expand Down
6 changes: 3 additions & 3 deletionssrc/path/pathbuf.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -364,9 +364,9 @@ impl From<std::path::PathBuf> for PathBuf {
}
}

implInto<std::path::PathBuf> forPathBuf {
fninto(self) ->std::path::PathBuf {
self.inner
implFrom<PathBuf> forstd::path::PathBuf {
fnfrom(val: PathBuf) ->Self {
val.inner
}
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/stream/from_fn.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ where
type Item = T;

fn poll_next(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let item = (&mutself.f)();
let item = (self.f)();
Poll::Ready(item)
}
}
2 changes: 1 addition & 1 deletionsrc/stream/repeat_with.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,7 @@ where
type Item = T;

fn poll_next(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let item = (&mutself.f)();
let item = (self.f)();
Poll::Ready(Some(item))
}
}
2 changes: 1 addition & 1 deletionsrc/stream/stream/all.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ where

match next {
Some(v) => {
let result = (&mutself.f)(v);
let result = (self.f)(v);

if result {
// don't forget to wake this task again to pull the next item from stream
Expand Down
2 changes: 1 addition & 1 deletionsrc/stream/stream/any.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ where

match next {
Some(v) => {
let result = (&mutself.f)(v);
let result = (self.f)(v);

if result {
Poll::Ready(true)
Expand Down
4 changes: 2 additions & 2 deletionssrc/stream/stream/find.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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,
Expand All@@ -30,7 +30,7 @@ where
let item = futures_core::ready!(Pin::new(&mut *self.stream).poll_next(cx));

match item {
Some(v) if (&mutself.p)(&v) => Poll::Ready(Some(v)),
Some(v) if (self.p)(&v) => Poll::Ready(Some(v)),
Some(_) => {
cx.waker().wake_by_ref();
Poll::Pending
Expand Down
4 changes: 2 additions & 2 deletionssrc/stream/stream/find_map.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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>,
Expand All@@ -30,7 +30,7 @@ where
let item = futures_core::ready!(Pin::new(&mut *self.stream).poll_next(cx));

match item {
Some(v) => match (&mutself.f)(v) {
Some(v) => match (self.f)(v) {
Some(v) => Poll::Ready(Some(v)),
None => {
cx.waker().wake_by_ref();
Expand Down
2 changes: 1 addition & 1 deletionsrc/stream/stream/nth.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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,
{
Expand Down
6 changes: 3 additions & 3 deletionssrc/stream/stream/position.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 {
Expand All@@ -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,
Expand All@@ -36,7 +36,7 @@ where

match next {
Some(v) => {
if (&mutself.predicate)(v) {
if (self.predicate)(v) {
Poll::Ready(Some(self.index))
} else {
cx.waker().wake_by_ref();
Expand Down
6 changes: 3 additions & 3 deletionssrc/stream/stream/try_fold.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 {
Expand All@@ -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>,
Expand All@@ -38,7 +38,7 @@ where
match next {
Some(v) => {
let old = self.acc.take().unwrap();
let new = (&mutself.f)(old, v);
let new = (self.f)(old, v);

match new {
Ok(o) => self.acc = Some(o),
Expand Down
6 changes: 3 additions & 3 deletionssrc/stream/stream/try_for_each.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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>,
Expand All@@ -33,7 +33,7 @@ where
match item {
None => return Poll::Ready(Ok(())),
Some(v) => {
let res = (&mutself.f)(v);
let res = (self.f)(v);
if let Err(e) = res {
return Poll::Ready(Err(e));
}
Expand Down
2 changes: 1 addition & 1 deletionsrc/task/builder.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ impl Builder {

thread_local! {
/// Tracks the number of nested block_on calls.
static NUM_NESTED_BLOCKING: Cell<usize> = Cell::new(0);
static NUM_NESTED_BLOCKING: Cell<usize> =const {Cell::new(0) };
}

// Run the future as a task.
Expand Down
2 changes: 1 addition & 1 deletionsrc/task/task_id.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ impl TaskId {
static COUNTER: AtomicUsize = AtomicUsize::new(1);

let id = COUNTER.fetch_add(1, Ordering::Relaxed);
if id > usize::max_value() / 2 {
if id > usize::MAX / 2 {
std::process::abort();
}
TaskId(id)
Expand Down
2 changes: 1 addition & 1 deletionsrc/task/task_local.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -120,7 +120,7 @@ impl<T: Send + 'static> LocalKey<T> {
static COUNTER: AtomicU32 = AtomicU32::new(1);

let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
if counter > u32::max_value() / 2 {
if counter > u32::MAX / 2 {
std::process::abort();
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/task/task_locals_wrapper.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ use crate::utils::abort_on_panic;

thread_local! {
/// A pointer to the currently running task.
static CURRENT: Cell<*const TaskLocalsWrapper> = Cell::new(ptr::null_mut());
static CURRENT: Cell<*const TaskLocalsWrapper> =const {Cell::new(ptr::null_mut()) };
}

/// A wrapper to store task local data.
Expand Down
2 changes: 1 addition & 1 deletionsrc/utils.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,7 +71,7 @@ pub(crate) fn timer_after(dur: std::time::Duration) -> timer::Timer {
Timer::after(dur)
}

#[cfg(any(all(target_arch = "wasm32", feature = "default"),))]
#[cfg(all(target_arch = "wasm32", feature = "default"))]
mod timer {
use std::pin::Pin;
use std::task::Poll;
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp