summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2019-10-26 17:40:38 +0200
committerCarl Lerche <me@carllerche.com>2019-10-26 08:40:38 -0700
commit474befd23c368a34a5f45aab0f3945212109a803 (patch)
tree0284891d5e80e191ab995f9cb517942b84fa2b2d /tokio
parent987ba7373cf95c570bf23768c6021f7a7508286e (diff)
chore: use argument position impl trait (#1690)
Diffstat (limited to 'tokio')
-rw-r--r--tokio/src/fs/create_dir.rs2
-rw-r--r--tokio/src/fs/create_dir_all.rs2
-rw-r--r--tokio/src/fs/file.rs10
-rw-r--r--tokio/src/fs/hard_link.rs2
-rw-r--r--tokio/src/fs/metadata.rs5
-rw-r--r--tokio/src/fs/open_options.rs5
-rw-r--r--tokio/src/fs/os/unix/symlink.rs2
-rw-r--r--tokio/src/fs/os/windows/symlink_dir.rs2
-rw-r--r--tokio/src/fs/os/windows/symlink_file.rs2
-rw-r--r--tokio/src/fs/read.rs5
-rw-r--r--tokio/src/fs/read_dir.rs5
-rw-r--r--tokio/src/fs/read_link.rs2
-rw-r--r--tokio/src/fs/read_to_string.rs5
-rw-r--r--tokio/src/fs/remove_dir.rs2
-rw-r--r--tokio/src/fs/remove_dir_all.rs2
-rw-r--r--tokio/src/fs/remove_file.rs2
-rw-r--r--tokio/src/fs/rename.rs2
-rw-r--r--tokio/src/fs/set_permissions.rs2
-rw-r--r--tokio/src/fs/symlink_metadata.rs5
-rw-r--r--tokio/src/fs/write.rs5
-rw-r--r--tokio/src/runtime/current_thread/runtime.rs5
-rw-r--r--tokio/src/runtime/threadpool/builder.rs2
-rw-r--r--tokio/src/runtime/threadpool/mod.rs8
-rw-r--r--tokio/src/timer/clock/mod.rs2
24 files changed, 27 insertions, 59 deletions
diff --git a/tokio/src/fs/create_dir.rs b/tokio/src/fs/create_dir.rs
index a74ca71d..99762058 100644
--- a/tokio/src/fs/create_dir.rs
+++ b/tokio/src/fs/create_dir.rs
@@ -8,7 +8,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::create_dir`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.create_dir.html
-pub async fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
+pub async fn create_dir(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::create_dir(path)).await
}
diff --git a/tokio/src/fs/create_dir_all.rs b/tokio/src/fs/create_dir_all.rs
index 2a7374a3..8c0c8df2 100644
--- a/tokio/src/fs/create_dir_all.rs
+++ b/tokio/src/fs/create_dir_all.rs
@@ -9,7 +9,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::create_dir_all`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.create_dir_all.html
-pub async fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
+pub async fn create_dir_all(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::create_dir_all(path)).await
}
diff --git a/tokio/src/fs/file.rs b/tokio/src/fs/file.rs
index aeb5dc28..9b81a278 100644
--- a/tokio/src/fs/file.rs
+++ b/tokio/src/fs/file.rs
@@ -115,10 +115,7 @@ impl File {
/// # Ok(())
/// # }
/// ```
- pub async fn open<P>(path: P) -> io::Result<File>
- where
- P: AsRef<Path>,
- {
+ pub async fn open(path: impl AsRef<Path>) -> io::Result<File> {
let path = path.as_ref().to_owned();
let std = asyncify(|| sys::File::open(path)).await?;
@@ -153,10 +150,7 @@ impl File {
/// # Ok(())
/// # }
/// ```
- pub async fn create<P>(path: P) -> io::Result<File>
- where
- P: AsRef<Path>,
- {
+ pub async fn create(path: impl AsRef<Path>) -> io::Result<File> {
let path = path.as_ref().to_owned();
let std_file = asyncify(move || sys::File::create(path)).await?;
Ok(File::from_std(std_file))
diff --git a/tokio/src/fs/hard_link.rs b/tokio/src/fs/hard_link.rs
index 564807a6..e3a32afc 100644
--- a/tokio/src/fs/hard_link.rs
+++ b/tokio/src/fs/hard_link.rs
@@ -11,7 +11,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::hard_link`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.hard_link.html
-pub async fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+pub async fn hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
let src = src.as_ref().to_owned();
let dst = dst.as_ref().to_owned();
diff --git a/tokio/src/fs/metadata.rs b/tokio/src/fs/metadata.rs
index d78294a0..3a830db3 100644
--- a/tokio/src/fs/metadata.rs
+++ b/tokio/src/fs/metadata.rs
@@ -5,10 +5,7 @@ use std::io;
use std::path::Path;
/// Queries the file system metadata for a path.
-pub async fn metadata<P>(path: P) -> io::Result<Metadata>
-where
- P: AsRef<Path>,
-{
+pub async fn metadata(path: impl AsRef<Path>) -> io::Result<Metadata> {
let path = path.as_ref().to_owned();
asyncify(|| std::fs::metadata(path)).await
}
diff --git a/tokio/src/fs/open_options.rs b/tokio/src/fs/open_options.rs
index ef88d9a7..8931247f 100644
--- a/tokio/src/fs/open_options.rs
+++ b/tokio/src/fs/open_options.rs
@@ -88,10 +88,7 @@ impl OpenOptions {
/// Tokio runtime or if the underlying [`open`] call results in an error.
///
/// [`open`]: https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.open
- pub async fn open<P>(&self, path: P) -> io::Result<File>
- where
- P: AsRef<Path>,
- {
+ pub async fn open(&self, path: impl AsRef<Path>) -> io::Result<File> {
let path = path.as_ref().to_owned();
let opts = self.0.clone();
diff --git a/tokio/src/fs/os/unix/symlink.rs b/tokio/src/fs/os/unix/symlink.rs
index c2a101dc..3d539446 100644
--- a/tokio/src/fs/os/unix/symlink.rs
+++ b/tokio/src/fs/os/unix/symlink.rs
@@ -10,7 +10,7 @@ use std::path::Path;
/// This is an async version of [`std::os::unix::fs::symlink`][std]
///
/// [std]: https://doc.rust-lang.org/std/os/unix/fs/fn.symlink.html
-pub async fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+pub async fn symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
let src = src.as_ref().to_owned();
let dst = dst.as_ref().to_owned();
diff --git a/tokio/src/fs/os/windows/symlink_dir.rs b/tokio/src/fs/os/windows/symlink_dir.rs
index 04692618..6753c25e 100644
--- a/tokio/src/fs/os/windows/symlink_dir.rs
+++ b/tokio/src/fs/os/windows/symlink_dir.rs
@@ -11,7 +11,7 @@ use std::path::Path;
/// This is an async version of [`std::os::windows::fs::symlink_dir`][std]
///
/// [std]: https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_dir.html
-pub async fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+pub async fn symlink_dir(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
let src = src.as_ref().to_owned();
let dst = dst.as_ref().to_owned();
diff --git a/tokio/src/fs/os/windows/symlink_file.rs b/tokio/src/fs/os/windows/symlink_file.rs
index da8d9d63..623352a1 100644
--- a/tokio/src/fs/os/windows/symlink_file.rs
+++ b/tokio/src/fs/os/windows/symlink_file.rs
@@ -11,7 +11,7 @@ use std::path::Path;
/// This is an async version of [`std::os::windows::fs::symlink_file`][std]
///
/// [std]: https://doc.rust-lang.org/std/os/windows/fs/fn.symlink_file.html
-pub async fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
+pub async fn symlink_file(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
let src = src.as_ref().to_owned();
let dst = dst.as_ref().to_owned();
diff --git a/tokio/src/fs/read.rs b/tokio/src/fs/read.rs
index 88211228..796acbf8 100644
--- a/tokio/src/fs/read.rs
+++ b/tokio/src/fs/read.rs
@@ -18,10 +18,7 @@ use std::{io, path::Path};
/// # Ok(())
/// # }
/// ```
-pub async fn read<P>(path: P) -> io::Result<Vec<u8>>
-where
- P: AsRef<Path>,
-{
+pub async fn read(path: impl AsRef<Path>) -> io::Result<Vec<u8>> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::read(path)).await
}
diff --git a/tokio/src/fs/read_dir.rs b/tokio/src/fs/read_dir.rs
index 03284b72..52208430 100644
--- a/tokio/src/fs/read_dir.rs
+++ b/tokio/src/fs/read_dir.rs
@@ -17,10 +17,7 @@ use std::task::Poll;
/// Returns a stream over the entries within a directory.
///
/// This is an async version of [`std::fs::read_dir`](std::fs::read_dir)
-pub async fn read_dir<P>(path: P) -> io::Result<ReadDir>
-where
- P: AsRef<Path>,
-{
+pub async fn read_dir(path: impl AsRef<Path>) -> io::Result<ReadDir> {
let path = path.as_ref().to_owned();
let std = asyncify(|| std::fs::read_dir(path)).await?;
diff --git a/tokio/src/fs/read_link.rs b/tokio/src/fs/read_link.rs
index 51786f97..6c48c5e1 100644
--- a/tokio/src/fs/read_link.rs
+++ b/tokio/src/fs/read_link.rs
@@ -8,7 +8,7 @@ use std::path::{Path, PathBuf};
/// This is an async version of [`std::fs::read_link`][std]
///
/// [std]: std::fs::read_link
-pub async fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
+pub async fn read_link(path: impl AsRef<Path>) -> io::Result<PathBuf> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::read_link(path)).await
}
diff --git a/tokio/src/fs/read_to_string.rs b/tokio/src/fs/read_to_string.rs
index 77149bfc..c743bb4d 100644
--- a/tokio/src/fs/read_to_string.rs
+++ b/tokio/src/fs/read_to_string.rs
@@ -18,10 +18,7 @@ use std::{io, path::Path};
/// # Ok(())
/// # }
/// ```
-pub async fn read_to_string<P>(path: P) -> io::Result<String>
-where
- P: AsRef<Path>,
-{
+pub async fn read_to_string(path: impl AsRef<Path>) -> io::Result<String> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::read_to_string(path)).await
}
diff --git a/tokio/src/fs/remove_dir.rs b/tokio/src/fs/remove_dir.rs
index 3989c1de..6e7cbd08 100644
--- a/tokio/src/fs/remove_dir.rs
+++ b/tokio/src/fs/remove_dir.rs
@@ -6,7 +6,7 @@ use std::path::Path;
/// Removes an existing, empty directory.
///
/// This is an async version of [`std::fs::remove_dir`](std::fs::remove_dir)
-pub async fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
+pub async fn remove_dir(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::remove_dir(path)).await
}
diff --git a/tokio/src/fs/remove_dir_all.rs b/tokio/src/fs/remove_dir_all.rs
index 50fe719b..3b2b2e04 100644
--- a/tokio/src/fs/remove_dir_all.rs
+++ b/tokio/src/fs/remove_dir_all.rs
@@ -8,7 +8,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::remove_dir_all`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html
-pub async fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
+pub async fn remove_dir_all(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::remove_dir_all(path)).await
}
diff --git a/tokio/src/fs/remove_file.rs b/tokio/src/fs/remove_file.rs
index 3921f55b..8ab162ca 100644
--- a/tokio/src/fs/remove_file.rs
+++ b/tokio/src/fs/remove_file.rs
@@ -12,7 +12,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::remove_file`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.remove_file.html
-pub async fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
+pub async fn remove_file(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(move || std::fs::remove_file(path)).await
}
diff --git a/tokio/src/fs/rename.rs b/tokio/src/fs/rename.rs
index dc9b8765..de647da9 100644
--- a/tokio/src/fs/rename.rs
+++ b/tokio/src/fs/rename.rs
@@ -9,7 +9,7 @@ use std::path::Path;
/// This will not work if the new name is on a different mount point.
///
/// This is an async version of [`std::fs::rename`](std::fs::rename)
-pub async fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
+pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
let from = from.as_ref().to_owned();
let to = to.as_ref().to_owned();
diff --git a/tokio/src/fs/set_permissions.rs b/tokio/src/fs/set_permissions.rs
index 6e640544..b6249d13 100644
--- a/tokio/src/fs/set_permissions.rs
+++ b/tokio/src/fs/set_permissions.rs
@@ -9,7 +9,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::set_permissions`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.set_permissions.html
-pub async fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> {
+pub async fn set_permissions(path: impl AsRef<Path>, perm: Permissions) -> io::Result<()> {
let path = path.as_ref().to_owned();
asyncify(|| std::fs::set_permissions(path, perm)).await
}
diff --git a/tokio/src/fs/symlink_metadata.rs b/tokio/src/fs/symlink_metadata.rs
index dc607971..682b43a7 100644
--- a/tokio/src/fs/symlink_metadata.rs
+++ b/tokio/src/fs/symlink_metadata.rs
@@ -9,10 +9,7 @@ use std::path::Path;
/// This is an async version of [`std::fs::symlink_metadata`][std]
///
/// [std]: https://doc.rust-lang.org/std/fs/fn.symlink_metadata.html
-pub async fn symlink_metadata<P>(path: P) -> io::Result<Metadata>
-where
- P: AsRef<Path>,
-{
+pub async fn symlink_metadata(path: impl AsRef<Path>) -> io::Result<Metadata> {
let path = path.as_ref().to_owned();
asyncify(|| std::fs::symlink_metadata(path)).await
}
diff --git a/tokio/src/fs/write.rs b/tokio/src/fs/write.rs
index 81176740..0114cab8 100644
--- a/tokio/src/fs/write.rs
+++ b/tokio/src/fs/write.rs
@@ -17,10 +17,7 @@ use std::{io, path::Path};
/// # Ok(())
/// # }
/// ```
-pub async fn write<P, C: AsRef<[u8]> + Unpin>(path: P, contents: C) -> io::Result<()>
-where
- P: AsRef<Path>,
-{
+pub async fn write<C: AsRef<[u8]> + Unpin>(path: impl AsRef<Path>, contents: C) -> io::Result<()> {
let path = path.as_ref().to_owned();
let contents = contents.as_ref().to_owned();
diff --git a/tokio/src/runtime/current_thread/runtime.rs b/tokio/src/runtime/current_thread/runtime.rs
index b6296559..f706c65c 100644
--- a/tokio/src/runtime/current_thread/runtime.rs
+++ b/tokio/src/runtime/current_thread/runtime.rs
@@ -164,10 +164,7 @@ impl Runtime {
///
/// The caller is responsible for ensuring that other spawned futures
/// complete execution by calling `block_on` or `run`.
- pub fn block_on<F>(&mut self, f: F) -> F::Output
- where
- F: Future,
- {
+ pub fn block_on<F: Future>(&mut self, f: F) -> F::Output {
self.enter(|executor| {
// Run the provided future
executor.block_on(f)
diff --git a/tokio/src/runtime/threadpool/builder.rs b/tokio/src/runtime/threadpool/builder.rs
index cc9fb577..3c94258f 100644
--- a/tokio/src/runtime/threadpool/builder.rs
+++ b/tokio/src/runtime/threadpool/builder.rs
@@ -125,7 +125,7 @@ impl Builder {
/// .build();
/// # }
/// ```
- pub fn name<S: Into<String>>(&mut self, val: S) -> &mut Self {
+ pub fn name(&mut self, val: impl Into<String>) -> &mut Self {
self.thread_pool_builder.name(val);
self
}
diff --git a/tokio/src/runtime/threadpool/mod.rs b/tokio/src/runtime/threadpool/mod.rs
index 983d2d28..2e6924ed 100644
--- a/tokio/src/runtime/threadpool/mod.rs
+++ b/tokio/src/runtime/threadpool/mod.rs
@@ -111,7 +111,8 @@ impl Runtime {
/// This function panics if the spawn fails. Failure occurs if the executor
/// is currently at capacity and is unable to spawn a new future.
pub fn spawn<F>(&self, future: F) -> &Self
- where F: Future<Output = ()> + Send + 'static,
+ where
+ F: Future<Output = ()> + Send + 'static,
{
self.inner().pool.spawn(future);
self
@@ -129,10 +130,7 @@ impl Runtime {
///
/// This function panics if the executor is at capacity, if the provided
/// future panics, or if called within an asynchronous execution context.
- pub fn block_on<F>(&self, future: F) -> F::Output
- where
- F: Future,
- {
+ pub fn block_on<F: Future>(&self, future: F) -> F::Output {
let _reactor = driver::set_default(&self.inner().reactor_handles[0]);
let _timer = timer::set_default(&self.inner().timer_handles[0]);
diff --git a/tokio/src/timer/clock/mod.rs b/tokio/src/timer/clock/mod.rs
index d7f7c31c..df2f2133 100644
--- a/tokio/src/timer/clock/mod.rs
+++ b/tokio/src/timer/clock/mod.rs
@@ -77,7 +77,7 @@ impl Clock {
}
/// Return a new `Clock` instance that uses `now` as the source of time.
- pub fn new_with_now<T: Now>(now: T) -> Clock {
+ pub fn new_with_now(now: impl Now) -> Clock {
Clock {
now: Some(Arc::new(now)),
}