Skip to content

Commit 5c9cfb4

Browse files
committed
Merge branch 'master' into add_future_delay
2 parents 53fa132 + b2fe913 commit 5c9cfb4

Some content is hidden

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

96 files changed

+3720
-1905
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
build_and_test:
1212
name: Build and test
1313
runs-on: ${{ matrix.os }}
14+
env:
15+
RUSTFLAGS: -Dwarnings
1416
strategy:
1517
matrix:
1618
os: [ubuntu-latest, windows-latest, macOS-latest]
@@ -29,7 +31,7 @@ jobs:
2931
uses: actions-rs/cargo@v1
3032
with:
3133
command: check
32-
args: --all --benches --bins --examples --tests
34+
args: --all --bins --examples
3335

3436
- name: check unstable
3537
uses: actions-rs/cargo@v1
@@ -41,11 +43,13 @@ jobs:
4143
uses: actions-rs/cargo@v1
4244
with:
4345
command: test
44-
args: --all --doc --features unstable
46+
args: --all --features unstable
4547

4648
check_fmt_and_docs:
4749
name: Checking fmt and docs
4850
runs-on: ubuntu-latest
51+
env:
52+
RUSTFLAGS: -Dwarnings
4953
steps:
5054
- uses: actions/checkout@master
5155

@@ -77,6 +81,9 @@ jobs:
7781
clippy_check:
7882
name: Clippy check
7983
runs-on: ubuntu-latest
84+
# TODO: There is a lot of warnings
85+
# env:
86+
# RUSTFLAGS: -Dwarnings
8087
steps:
8188
- uses: actions/checkout@v1
8289
- id: component

CHANGELOG.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,104 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview
77

88
## [Unreleased]
99

10+
# [0.99.10] - 2019-10-16
11+
12+
This patch stabilizes several core concurrency macros, introduces async versions
13+
of `Path` and `PathBuf`, and adds almost 100 other commits.
14+
15+
## Examples
16+
17+
__Asynchronously read directories from the filesystem__
18+
```rust
19+
use async_std::fs;
20+
use async_std::path::Path;
21+
use async_std::prelude::*;
22+
23+
let path = Path::new("/laputa");
24+
let mut dir = fs::read_dir(&path).await.unwrap();
25+
while let Some(entry) = dir.next().await {
26+
if let Ok(entry) = entry {
27+
println!("{:?}", entry.path());
28+
}
29+
}
30+
```
31+
32+
__Cooperatively reschedule the current task on the executor__
33+
```rust
34+
use async_std::prelude::*;
35+
use async_std::task;
36+
37+
task::spawn(async {
38+
let x = fibonnacci(1000); // Do expensive work
39+
task::yield_now().await; // Allow other tasks to run
40+
x + fibonnacci(100) // Do more work
41+
})
42+
```
43+
44+
__Create an interval stream__
45+
```rust
46+
use async_std::prelude::*;
47+
use async_std::stream;
48+
use std::time::Duration;
49+
50+
let mut interval = stream::interval(Duration::from_secs(4));
51+
while let Some(_) = interval.next().await {
52+
println!("prints every four seconds");
53+
}
54+
```
55+
56+
## Added
57+
58+
- Added `FutureExt` to the `prelude`, allowing us to extend `Future`
59+
- Added `Stream::cmp`
60+
- Added `Stream::ge`
61+
- Added `Stream::last`
62+
- Added `Stream::le`
63+
- Added `Stream::lt`
64+
- Added `Stream::merge` as "unstable", replacing `stream::join!`
65+
- Added `Stream::partial_cmp`
66+
- Added `Stream::take_while`
67+
- Added `Stream::try_fold`
68+
- Added `future::IntoFuture` as "unstable"
69+
- Added `io::BufRead::split`
70+
- Added `io::Write::write_fmt`
71+
- Added `print!`, `println!`, `eprint!`, `eprintln!` macros as "unstable"
72+
- Added `process` as "unstable", re-exporting std types only for now
73+
- Added `std::net` re-exports to the `net` submodule
74+
- Added `std::path::PathBuf` with all associated methods
75+
- Added `std::path::Path` with all associated methods
76+
- Added `stream::ExactSizeStream` as "unstable"
77+
- Added `stream::FusedStream` as "unstable"
78+
- Added `stream::Product`
79+
- Added `stream::Sum`
80+
- Added `stream::from_fn`
81+
- Added `stream::interval` as "unstable"
82+
- Added `stream::repeat_with`
83+
- Added `task::spawn_blocking` as "unstable", replacing `task::blocking`
84+
- Added `task::yield_now`
85+
- Added `write!` and `writeln!` macros as "unstable"
86+
- Stabilized `future::join!` and `future::try_join!`
87+
- Stabilized `future::timeout`
88+
- Stabilized `path`
89+
- Stabilized `task::ready!`
90+
91+
## Changed
92+
93+
- Fixed `BufWriter::into_inner` so it calls `flush` before yielding
94+
- Refactored `io::BufWriter` internals
95+
- Refactored `net::ToSocketAddrs` internals
96+
- Removed Travis CI entirely
97+
- Rewrote the README.md
98+
- Stabilized `io::Cursor`
99+
- Switched bors over to use GitHub actions
100+
- Updated the `io` documentation to match std's `io` docs
101+
- Updated the `task` documentation to match std's `thread` docs
102+
103+
## Removed
104+
105+
- Removed the "unstable" `stream::join!` in favor of `Stream::merge`
106+
- Removed the "unstable" `task::blocking` in favor of `task::spawn_blocking`
107+
10108
# [0.99.9] - 2019-10-08
11109

12110
This patch upgrades our `futures-rs` version, allowing us to build on the 1.39
@@ -183,7 +281,8 @@ task::blocking(async {
183281

184282
- Initial beta release
185283

186-
[Unreleased]: https://github.com/async-rs/async-std/compare/v0.99.9...HEAD
284+
[Unreleased]: https://github.com/async-rs/async-std/compare/v0.99.10...HEAD
285+
[0.99.10]: https://github.com/async-rs/async-std/compare/v0.99.9...v0.99.10
187286
[0.99.9]: https://github.com/async-rs/async-std/compare/v0.99.8...v0.99.9
188287
[0.99.8]: https://github.com/async-rs/async-std/compare/v0.99.7...v0.99.8
189288
[0.99.7]: https://github.com/async-rs/async-std/compare/v0.99.6...v0.99.7

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-std"
3-
version = "0.99.9"
3+
version = "0.99.10"
44
authors = [
55
"Stjepan Glavina <stjepang@gmail.com>",
66
"Yoshua Wuyts <yoshuawuyts@gmail.com>",
@@ -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"
@@ -43,9 +43,11 @@ pin-utils = "0.1.0-alpha.4"
4343
slab = "0.4.2"
4444
kv-log-macro = "1.0.4"
4545
broadcaster = { version = "0.2.6", optional = true, default-features = false, features = ["default-channels"] }
46+
pin-project-lite = "0.1"
4647

4748
[dev-dependencies]
4849
femme = "1.2.0"
50+
rand = "0.7.2"
4951
# surf = "1.0.2"
5052
tempdir = "0.3.7"
5153
futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] }

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
}

0 commit comments

Comments
 (0)