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

Commit 4f4a017

Browse files
Merge branch 'master' into stream_peekable
2 parents 8f2ed48 + ec23632 commit 4f4a017

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+945
-1085
lines changed

‎.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions-rs/cargo@v1
4242
with:
4343
command: test
44-
args: --all --doc --features unstable
44+
args: --all --features unstable
4545

4646
check_fmt_and_docs:
4747
name: Checking fmt and docs

‎Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ features = ["docs"]
2121
rustdoc-args = ["--cfg", "feature=\"docs\""]
2222

2323
[features]
24-
docs = ["broadcaster"]
24+
docs = ["unstable"]
2525
unstable = ["broadcaster"]
2626

2727
[dependencies]
2828
async-macros = "1.0.0"
2929
async-task = "1.0.0"
30-
cfg-if = "0.1.9"
3130
crossbeam-channel = "0.3.9"
3231
crossbeam-deque = "0.7.1"
32+
crossbeam-utils = "0.6.6"
3333
futures-core-preview = "=0.3.0-alpha.19"
3434
futures-io-preview = "=0.3.0-alpha.19"
3535
futures-timer = "1.0.2"

‎src/fs/dir_builder.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::future::Future;
22

3-
use cfg_if::cfg_if;
4-
53
use crate::io;
64
use crate::path::Path;
75
use crate::task::blocking;
@@ -113,22 +111,13 @@ impl DirBuilder {
113111
}
114112
}
115113

116-
cfg_if! {
117-
if #[cfg(feature = "docs")] {
118-
use crate::os::unix::fs::DirBuilderExt;
119-
} else if #[cfg(unix)] {
120-
use std::os::unix::fs::DirBuilderExt;
121-
}
122-
}
114+
cfg_unix! {
115+
use crate::os::unix::fs::DirBuilderExt;
123116

124-
#[cfg_attr(feature = "docs", doc(cfg(unix)))]
125-
cfg_if! {
126-
if #[cfg(any(unix, feature = "docs"))] {
127-
impl DirBuilderExt for DirBuilder {
128-
fn mode(&mut self, mode: u32) -> &mut Self {
129-
self.mode = Some(mode);
130-
self
131-
}
117+
impl DirBuilderExt for DirBuilder {
118+
fn mode(&mut self, mode: u32) -> &mut Self {
119+
self.mode = Some(mode);
120+
self
132121
}
133122
}
134123
}

‎src/fs/dir_entry.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use std::ffi::OsString;
22
use std::fmt;
33
use std::sync::Arc;
44

5-
use cfg_if::cfg_if;
6-
75
use crate::fs::{FileType, Metadata};
86
use crate::io;
97
use crate::path::PathBuf;
@@ -160,21 +158,12 @@ impl fmt::Debug for DirEntry {
160158
}
161159
}
162160

163-
cfg_if! {
164-
if #[cfg(feature = "docs")] {
165-
use crate::os::unix::fs::DirEntryExt;
166-
} else if #[cfg(unix)] {
167-
use std::os::unix::fs::DirEntryExt;
168-
}
169-
}
161+
cfg_unix! {
162+
use crate::os::unix::fs::DirEntryExt;
170163

171-
#[cfg_attr(feature = "docs", doc(cfg(unix)))]
172-
cfg_if! {
173-
if #[cfg(any(unix, feature = "docs"))] {
174-
impl DirEntryExt for DirEntry {
175-
fn ino(&self) -> u64 {
176-
self.0.ino()
177-
}
164+
impl DirEntryExt for DirEntry {
165+
fn ino(&self) -> u64 {
166+
self.0.ino()
178167
}
179168
}
180169
}

‎src/fs/file.rs

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use std::pin::Pin;
77
use std::sync::atomic::{AtomicBool, Ordering};
88
use std::sync::{Arc, Mutex};
99

10-
use cfg_if::cfg_if;
11-
1210
use crate::fs::{Metadata, Permissions};
1311
use crate::future;
1412
use crate::io::{self, Read, Seek, SeekFrom, Write};
@@ -401,67 +399,54 @@ impl From<std::fs::File> for File {
401399
}
402400
}
403401

404-
cfg_if! {
405-
if #[cfg(feature = "docs")] {
406-
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
407-
use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
408-
} else if #[cfg(unix)] {
409-
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
410-
} else if #[cfg(windows)] {
411-
use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
412-
}
413-
}
402+
cfg_unix! {
403+
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
414404

415-
#[cfg_attr(feature = "docs", doc(cfg(unix)))]
416-
cfg_if! {
417-
if #[cfg(any(unix, feature = "docs"))] {
418-
impl AsRawFd for File {
419-
fn as_raw_fd(&self) -> RawFd {
420-
self.file.as_raw_fd()
421-
}
405+
impl AsRawFd for File {
406+
fn as_raw_fd(&self) -> RawFd {
407+
self.file.as_raw_fd()
422408
}
409+
}
423410

424-
impl FromRawFd for File {
425-
unsafe fn from_raw_fd(fd: RawFd) -> File {
426-
std::fs::File::from_raw_fd(fd).into()
427-
}
411+
impl FromRawFd for File {
412+
unsafe fn from_raw_fd(fd: RawFd) -> File {
413+
std::fs::File::from_raw_fd(fd).into()
428414
}
415+
}
429416

430-
impl IntoRawFd for File {
431-
fn into_raw_fd(self) -> RawFd {
432-
let file = self.file.clone();
433-
drop(self);
434-
Arc::try_unwrap(file)
435-
.expect("cannot acquire ownership of the file handle after drop")
436-
.into_raw_fd()
437-
}
417+
impl IntoRawFd for File {
418+
fn into_raw_fd(self) -> RawFd {
419+
let file = self.file.clone();
420+
drop(self);
421+
Arc::try_unwrap(file)
422+
.expect("cannot acquire ownership of the file handle after drop")
423+
.into_raw_fd()
438424
}
439425
}
440426
}
441427

442-
#[cfg_attr(feature = "docs", doc(cfg(windows)))]
443-
cfg_if! {
444-
if #[cfg(any(windows, feature = "docs"))] {
445-
impl AsRawHandle for File {
446-
fn as_raw_handle(&self) -> RawHandle {
447-
self.file.as_raw_handle()
448-
}
428+
cfg_windows! {
429+
use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
430+
431+
impl AsRawHandle for File {
432+
fn as_raw_handle(&self) -> RawHandle {
433+
self.file.as_raw_handle()
449434
}
435+
}
450436

451-
impl FromRawHandle for File {
452-
unsafe fn from_raw_handle(handle: RawHandle) -> File {
453-
std::fs::File::from_raw_handle(handle).into()
454-
}
437+
impl FromRawHandle for File {
438+
unsafe fn from_raw_handle(handle: RawHandle) -> File {
439+
std::fs::File::from_raw_handle(handle).into()
455440
}
441+
}
456442

457-
impl IntoRawHandle for File {
458-
fn into_raw_handle(self) -> RawHandle {
459-
let file = self.file.clone();
460-
drop(self);
461-
Arc::try_unwrap(file)
462-
.expect("cannot acquire ownership of the file handle after drop")
463-
.into_raw_handle()
464-
}
443+
impl IntoRawHandle for File {
444+
fn into_raw_handle(self) -> RawHandle {
445+
let file = self.file.clone();
446+
drop(self);
447+
Arc::try_unwrap(file)
448+
.expect("cannot acquire ownership of the file handle after drop")
449+
.into_raw_handle()
465450
}
466451
}
467452
}

‎src/fs/file_type.rs

Lines changed: 73 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,84 @@
1-
use cfg_if::cfg_if;
1+
cfg_not_docs! {
2+
pub use std::fs::FileType;
3+
}
4+
5+
cfg_docs! {
6+
/// The type of a file or directory.
7+
///
8+
/// A file type is returned by [`Metadata::file_type`].
9+
///
10+
/// Note that file types are mutually exclusive, i.e. at most one of methods [`is_dir`],
11+
/// [`is_file`], and [`is_symlink`] can return `true`.
12+
///
13+
/// This type is a re-export of [`std::fs::FileType`].
14+
///
15+
/// [`Metadata::file_type`]: struct.Metadata.html#method.file_type
16+
/// [`is_dir`]: #method.is_dir
17+
/// [`is_file`]: #method.is_file
18+
/// [`is_symlink`]: #method.is_symlink
19+
/// [`std::fs::FileType`]: https://doc.rust-lang.org/std/fs/struct.FileType.html
20+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
21+
pub struct FileType {
22+
_private: (),
23+
}
224

3-
cfg_if! {
4-
if #[cfg(feature = "docs")] {
5-
/// The type of a file or directory.
25+
impl FileType {
26+
/// Returns `true` if this file type represents a regular directory.
627
///
7-
/// A file type is returned by [`Metadata::file_type`].
28+
/// If this file type represents a symbolic link, this method returns `false`.
829
///
9-
/// Note that file types are mutually exclusive, i.e. at most one of methods [`is_dir`],
10-
/// [`is_file`], and [`is_symlink`] can return `true`.
30+
/// # Examples
1131
///
12-
/// This type is a re-export of [`std::fs::FileType`].
32+
/// ```no_run
33+
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
34+
/// #
35+
/// use async_std::fs;
1336
///
14-
/// [`Metadata::file_type`]: struct.Metadata.html#method.file_type
15-
/// [`is_dir`]: #method.is_dir
16-
/// [`is_file`]: #method.is_file
17-
/// [`is_symlink`]: #method.is_symlink
18-
/// [`std::fs::FileType`]: https://doc.rust-lang.org/std/fs/struct.FileType.html
19-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
20-
pub struct FileType {
21-
_private: (),
37+
/// let file_type = fs::metadata(".").await?.file_type();
38+
/// println!("{:?}", file_type.is_dir());
39+
/// #
40+
/// # Ok(()) }) }
41+
/// ```
42+
pub fn is_dir(&self) -> bool {
43+
unimplemented!()
2244
}
2345

24-
impl FileType {
25-
/// Returns `true` if this file type represents a regular directory.
26-
///
27-
/// If this file type represents a symbolic link, this method returns `false`.
28-
///
29-
/// # Examples
30-
///
31-
/// ```no_run
32-
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
33-
/// #
34-
/// use async_std::fs;
35-
///
36-
/// let file_type = fs::metadata(".").await?.file_type();
37-
/// println!("{:?}", file_type.is_dir());
38-
/// #
39-
/// # Ok(()) }) }
40-
/// ```
41-
pub fn is_dir(&self) -> bool {
42-
unimplemented!()
43-
}
44-
45-
/// Returns `true` if this file type represents a regular file.
46-
///
47-
/// If this file type represents a symbolic link, this method returns `false`.
48-
///
49-
/// # Examples
50-
///
51-
/// ```no_run
52-
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
53-
/// #
54-
/// use async_std::fs;
55-
///
56-
/// let file_type = fs::metadata("a.txt").await?.file_type();
57-
/// println!("{:?}", file_type.is_file());
58-
/// #
59-
/// # Ok(()) }) }
60-
/// ```
61-
pub fn is_file(&self) -> bool {
62-
unimplemented!()
63-
}
46+
/// Returns `true` if this file type represents a regular file.
47+
///
48+
/// If this file type represents a symbolic link, this method returns `false`.
49+
///
50+
/// # Examples
51+
///
52+
/// ```no_run
53+
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
54+
/// #
55+
/// use async_std::fs;
56+
///
57+
/// let file_type = fs::metadata("a.txt").await?.file_type();
58+
/// println!("{:?}", file_type.is_file());
59+
/// #
60+
/// # Ok(()) }) }
61+
/// ```
62+
pub fn is_file(&self) -> bool {
63+
unimplemented!()
64+
}
6465

65-
/// Returns `true` if this file type represents a symbolic link.
66-
///
67-
/// # Examples
68-
///
69-
/// ```no_run
70-
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
71-
/// #
72-
/// use async_std::fs;
73-
///
74-
/// let file_type = fs::metadata("a.txt").await?.file_type();
75-
/// println!("{:?}", file_type.is_symlink());
76-
/// #
77-
/// # Ok(()) }) }
78-
/// ```
79-
pub fn is_symlink(&self) -> bool {
80-
unimplemented!()
81-
}
66+
/// Returns `true` if this file type represents a symbolic link.
67+
///
68+
/// # Examples
69+
///
70+
/// ```no_run
71+
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
72+
/// #
73+
/// use async_std::fs;
74+
///
75+
/// let file_type = fs::metadata("a.txt").await?.file_type();
76+
/// println!("{:?}", file_type.is_symlink());
77+
/// #
78+
/// # Ok(()) }) }
79+
/// ```
80+
pub fn is_symlink(&self) -> bool {
81+
unimplemented!()
8282
}
83-
} else {
84-
pub use std::fs::FileType;
8583
}
8684
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /