From 474befd23c368a34a5f45aab0f3945212109a803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sat, 26 Oct 2019 17:40:38 +0200 Subject: chore: use argument position impl trait (#1690) --- tokio/src/fs/create_dir.rs | 2 +- tokio/src/fs/create_dir_all.rs | 2 +- tokio/src/fs/file.rs | 10 ++-------- tokio/src/fs/hard_link.rs | 2 +- tokio/src/fs/metadata.rs | 5 +---- tokio/src/fs/open_options.rs | 5 +---- tokio/src/fs/os/unix/symlink.rs | 2 +- tokio/src/fs/os/windows/symlink_dir.rs | 2 +- tokio/src/fs/os/windows/symlink_file.rs | 2 +- tokio/src/fs/read.rs | 5 +---- tokio/src/fs/read_dir.rs | 5 +---- tokio/src/fs/read_link.rs | 2 +- tokio/src/fs/read_to_string.rs | 5 +---- tokio/src/fs/remove_dir.rs | 2 +- tokio/src/fs/remove_dir_all.rs | 2 +- tokio/src/fs/remove_file.rs | 2 +- tokio/src/fs/rename.rs | 2 +- tokio/src/fs/set_permissions.rs | 2 +- tokio/src/fs/symlink_metadata.rs | 5 +---- tokio/src/fs/write.rs | 5 +---- 20 files changed, 21 insertions(+), 48 deletions(-) (limited to 'tokio/src/fs') 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>(path: P) -> io::Result<()> { +pub async fn create_dir(path: impl AsRef) -> 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>(path: P) -> io::Result<()> { +pub async fn create_dir_all(path: impl AsRef) -> 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

(path: P) -> io::Result - where - P: AsRef, - { + pub async fn open(path: impl AsRef) -> io::Result { 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

(path: P) -> io::Result - where - P: AsRef, - { + pub async fn create(path: impl AsRef) -> io::Result { 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, Q: AsRef>(src: P, dst: Q) -> io::Result<()> { +pub async fn hard_link(src: impl AsRef, dst: impl AsRef) -> 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

(path: P) -> io::Result -where - P: AsRef, -{ +pub async fn metadata(path: impl AsRef) -> io::Result { 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

(&self, path: P) -> io::Result - where - P: AsRef, - { + pub async fn open(&self, path: impl AsRef) -> io::Result { 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, Q: AsRef>(src: P, dst: Q) -> io::Result<()> { +pub async fn symlink(src: impl AsRef, dst: impl AsRef) -> 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, Q: AsRef>(src: P, dst: Q) -> io::Result<()> { +pub async fn symlink_dir(src: impl AsRef, dst: impl AsRef) -> 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, Q: AsRef>(src: P, dst: Q) -> io::Result<()> { +pub async fn symlink_file(src: impl AsRef, dst: impl AsRef) -> 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

(path: P) -> io::Result> -where - P: AsRef, -{ +pub async fn read(path: impl AsRef) -> io::Result> { 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

(path: P) -> io::Result -where - P: AsRef, -{ +pub async fn read_dir(path: impl AsRef) -> io::Result { 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>(path: P) -> io::Result { +pub async fn read_link(path: impl AsRef) -> io::Result { 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

(path: P) -> io::Result -where - P: AsRef, -{ +pub async fn read_to_string(path: impl AsRef) -> io::Result { 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>(path: P) -> io::Result<()> { +pub async fn remove_dir(path: impl AsRef) -> 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>(path: P) -> io::Result<()> { +pub async fn remove_dir_all(path: impl AsRef) -> 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>(path: P) -> io::Result<()> { +pub async fn remove_file(path: impl AsRef) -> 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, Q: AsRef>(from: P, to: Q) -> io::Result<()> { +pub async fn rename(from: impl AsRef, to: impl AsRef) -> 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>(path: P, perm: Permissions) -> io::Result<()> { +pub async fn set_permissions(path: impl AsRef, 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

(path: P) -> io::Result -where - P: AsRef, -{ +pub async fn symlink_metadata(path: impl AsRef) -> io::Result { 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 + Unpin>(path: P, contents: C) -> io::Result<()> -where - P: AsRef, -{ +pub async fn write + Unpin>(path: impl AsRef, contents: C) -> io::Result<()> { let path = path.as_ref().to_owned(); let contents = contents.as_ref().to_owned(); -- cgit v1.2.3