mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
fs: misc small API tweaks (#3315)
This commit is contained in:
@@ -20,7 +20,7 @@ use std::path::Path;
|
||||
/// # }
|
||||
/// ```
|
||||
|
||||
pub async fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64, std::io::Error> {
|
||||
pub async fn copy(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64, std::io::Error> {
|
||||
let from = from.as_ref().to_owned();
|
||||
let to = to.as_ref().to_owned();
|
||||
asyncify(|| std::fs::copy(from, to)).await
|
||||
|
||||
@@ -96,7 +96,7 @@ impl DirBuilder {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn create<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
|
||||
pub async fn create(&self, path: impl AsRef<Path>) -> io::Result<()> {
|
||||
let path = path.as_ref().to_owned();
|
||||
let mut builder = std::fs::DirBuilder::new();
|
||||
builder.recursive(self.recursive);
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::{io, path::Path};
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub async fn write<C: AsRef<[u8]> + Unpin>(path: impl AsRef<Path>, contents: C) -> io::Result<()> {
|
||||
pub async fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> io::Result<()> {
|
||||
let path = path.as_ref().to_owned();
|
||||
let contents = contents.as_ref().to_owned();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user