Skip to content

Commit b7f94ed

Browse files
committed
Merge remote-tracking branch 'origin/master' into condvar
2 parents 811280e + 125fa5b commit b7f94ed

File tree

141 files changed

+2218
-534
lines changed

Some content is hidden

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

141 files changed

+2218
-534
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Our contribution policy can be found at [async.rs/contribute][policy].
2+
3+
[policy]: https://async.rs/contribute/

.github/workflows/ci.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
push:
66
branches:
7+
- master
78
- staging
89
- trying
910

@@ -39,6 +40,7 @@ jobs:
3940
with:
4041
command: check
4142
args: --features unstable --all --bins --examples --tests
43+
4244
- name: check bench
4345
uses: actions-rs/cargo@v1
4446
if: matrix.rust == 'nightly'
@@ -62,7 +64,31 @@ jobs:
6264
uses: actions-rs/cargo@v1
6365
with:
6466
command: test
65-
args: --all --features unstable attributes
67+
args: --all --features "unstable attributes"
68+
69+
- name: documentation test
70+
uses: actions-rs/cargo@v1
71+
with:
72+
command: test
73+
args: --doc --features "unstable attributes"
74+
75+
build__with_no_std:
76+
name: Build with no-std
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- uses: actions/checkout@master
81+
82+
- name: setup
83+
run: |
84+
rustup default nightly
85+
rustup target add thumbv7m-none-eabi
86+
87+
- name: check no_std
88+
uses: actions-rs/cargo@v1
89+
with:
90+
command: check
91+
args: --no-default-features --features alloc --target thumbv7m-none-eabi -Z avoid-dev-deps
6692

6793
check_fmt_and_docs:
6894
name: Checking fmt and docs

CHANGELOG.md

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

88
## [Unreleased]
99

10+
# [1.5.0] - 2020-02-03
11+
12+
[API Documentation](https://docs.rs/async-std/1.5.0/async-std)
13+
14+
This patch includes various quality of life improvements to async-std.
15+
Including improved performance, stability, and the addition of various
16+
`Clone` impls that replace the use of `Arc` in many cases.
17+
18+
## Added
19+
20+
- Added links to various ecosystem projects from the README ([#660](https://github.com/async-rs/async-std/pull/660))
21+
- Added an example on `FromStream` for `Result<T, E>` ([#643](https://github.com/async-rs/async-std/pull/643))
22+
- Added `stream::pending` as "unstable" ([#615](https://github.com/async-rs/async-std/pull/615))
23+
- Added an example of `stream::timeout` to document the error flow ([#675](https://github.com/async-rs/async-std/pull/675))
24+
- Implement `Clone` for `DirEntry` ([#682](https://github.com/async-rs/async-std/pull/682))
25+
- Implement `Clone` for `TcpStream` ([#689](https://github.com/async-rs/async-std/pull/689))
26+
27+
## Changed
28+
29+
- Removed internal comment on `stream::Interval` ([#645](https://github.com/async-rs/async-std/pull/645))
30+
- The "unstable" feature can now be used without requiring the "default" feature ([#647](https://github.com/async-rs/async-std/pull/647))
31+
- Removed unnecessary trait bound on `stream::FlatMap` ([#651](https://github.com/async-rs/async-std/pull/651))
32+
- Updated the "broadcaster" dependency used by "unstable" to `1.0.0` ([#681](https://github.com/async-rs/async-std/pull/681))
33+
- Updated `async-task` to 1.2.1 ([#676](https://github.com/async-rs/async-std/pull/676))
34+
- `task::block_on` now parks after a single poll, improving performance in many cases ([#684](https://github.com/async-rs/async-std/pull/684))
35+
- Improved reading flow of the "client" part of the async-std tutorial ([#550](https://github.com/async-rs/async-std/pull/550))
36+
- Use `take_while` instead of `scan` in `impl` of `Product`, `Sum` and `FromStream` ([#667](https://github.com/async-rs/async-std/pull/667))
37+
- `TcpStream::connect` no longer uses a thread from the threadpool, improving performance ([#687](https://github.com/async-rs/async-std/pull/687))
38+
39+
## Fixed
40+
41+
- Fixed crate documentation typo ([#655](https://github.com/async-rs/async-std/pull/655))
42+
- Fixed documentation for `UdpSocket::recv` ([#648](https://github.com/async-rs/async-std/pull/648))
43+
- Fixed documentation for `UdpSocket::send` ([#671](https://github.com/async-rs/async-std/pull/671))
44+
- Fixed typo in stream documentation ([#650](https://github.com/async-rs/async-std/pull/650))
45+
- Fixed typo on `sync::JoinHandle` documentation ([#659](https://github.com/async-rs/async-std/pull/659))
46+
- Removed use of `std::error::Error::description` which failed CI ([#661](https://github.com/async-rs/async-std/pull/662))
47+
- Removed the use of rustfmt's unstable `format_code_in_doc_comments` option which failed CI ([#685](https://github.com/async-rs/async-std/pull/685))
48+
- Fixed a code typo in the `task::sleep` example ([#688](https://github.com/async-rs/async-std/pull/688))
49+
50+
# [1.4.0] - 2019-12-20
51+
52+
[API Documentation](https://docs.rs/async-std/1.4.0/async-std)
53+
54+
This patch adds `Future::timeout`, providing a method counterpart to the
55+
`future::timeout` free function. And includes several bug fixes around missing
56+
APIs. Notably we're not shipping our new executor yet, first announced [on our
57+
blog](https://async.rs/blog/stop-worrying-about-blocking-the-new-async-std-runtime/).
58+
59+
## Examples
60+
61+
```rust
62+
use async_std::prelude::*;
63+
use async_std::future;
64+
use std::time::Duration;
65+
66+
let fut = future::pending::<()>(); // This future will never resolve.
67+
let res = fut.timeout(Duration::from_millis(100)).await;
68+
assert!(res.is_err()); // The future timed out, returning an err.
69+
```
70+
71+
## Added
72+
73+
- Added `Future::timeout` as "unstable" [(#600)](https://github.com/async-rs/async-std/pull/600)
74+
75+
## Fixes
76+
77+
- Fixed a doc test and enabled it on CI [(#597)](https://github.com/async-rs/async-std/pull/597)
78+
- Fixed a rendering issue with the `stream` submodule documentation [(#621)](https://github.com/async-rs/async-std/pull/621)
79+
- `Write::write_fmt`'s future is now correctly marked as `#[must_use]` [(#628)](https://github.com/async-rs/async-std/pull/628)
80+
- Fixed the missing `io::Bytes` export [(#633)](https://github.com/async-rs/async-std/pull/633)
81+
- Fixed the missing `io::Chain` export [(#633)](https://github.com/async-rs/async-std/pull/633)
82+
- Fixed the missing `io::Take` export [(#633)](https://github.com/async-rs/async-std/pull/633)
83+
84+
# [1.3.0] - 2019-12-12
85+
86+
[API Documentation](https://docs.rs/async-std/1.3.0/async-std)
87+
88+
This patch introduces `Stream::delay`, more methods on `DoubleEndedStream`,
89+
and improves compile times. `Stream::delay` is a new API that's similar to
90+
[`task::sleep`](https://docs.rs/async-std/1.2.0/async_std/task/fn.sleep.html),
91+
but can be passed as part of as stream, rather than as a separate block. This is
92+
useful for examples, or when manually debugging race conditions.
93+
94+
## Examples
95+
96+
```rust
97+
let start = Instant::now();
98+
let mut s = stream::from_iter(vec![0u8, 1]).delay(Duration::from_millis(200));
99+
100+
// The first time will take more than 200ms due to delay.
101+
s.next().await;
102+
assert!(start.elapsed().as_millis() >= 200);
103+
104+
// There will be no delay after the first time.
105+
s.next().await;
106+
assert!(start.elapsed().as_millis() <= 210);
107+
```
108+
109+
## Added
110+
111+
- Added `Stream::delay` as "unstable" [(#309)](https://github.com/async-rs/async-std/pull/309)
112+
- Added `DoubleEndedStream::next_back` as "unstable" [(#562)](https://github.com/async-rs/async-std/pull/562)
113+
- Added `DoubleEndedStream::nth_back` as "unstable" [(#562)](https://github.com/async-rs/async-std/pull/562)
114+
- Added `DoubleEndedStream::rfind` as "unstable" [(#562)](https://github.com/async-rs/async-std/pull/562)
115+
- Added `DoubleEndedStream::rfold` as "unstable" [(#562)](https://github.com/async-rs/async-std/pull/562)
116+
- Added `DoubleEndedStream::try_rfold` as "unstable" [(#562)](https://github.com/async-rs/async-std/pull/562)
117+
- `stream::Once` now implements `DoubleEndedStream` [(#562)](https://github.com/async-rs/async-std/pull/562)
118+
- `stream::FromIter` now implements `DoubleEndedStream` [(#562)](https://github.com/async-rs/async-std/pull/562)
119+
120+
## Changed
121+
122+
- Removed our dependency on `async-macros`, speeding up compilation [(#610)](https://github.com/async-rs/async-std/pull/610)
123+
124+
## Fixes
125+
126+
- Fixed a link in the task docs [(#598)](https://github.com/async-rs/async-std/pull/598)
127+
- Fixed the `UdpSocket::recv` example [(#603)](https://github.com/async-rs/async-std/pull/603)
128+
- Fixed a link to `task::block_on` [(#608)](https://github.com/async-rs/async-std/pull/608)
129+
- Fixed an incorrect API mention in `task::Builder` [(#612)](https://github.com/async-rs/async-std/pull/612)
130+
- Fixed leftover mentions of `futures-preview` [(#595)](https://github.com/async-rs/async-std/pull/595)
131+
- Fixed a typo in the tutorial [(#614)](https://github.com/async-rs/async-std/pull/614)
132+
- `<TcpStream as Write>::poll_close` now closes the write half of the stream [(#618)](https://github.com/async-rs/async-std/pull/618)
133+
134+
# [1.2.0] - 2019-11-27
135+
136+
[API Documentation](https://docs.rs/async-std/1.2.0/async-std)
137+
138+
This patch includes some minor quality-of-life improvements, introduces a
139+
new `Stream::unzip` API, and adds verbose errors to our networking types.
140+
141+
This means if you can't connect to a socket, you'll never have to wonder again
142+
*which* address it was you couldn't connect to, instead of having to go through
143+
the motions to debug what the address was.
144+
145+
## Example
146+
147+
Unzip a stream of tuples into two collections:
148+
149+
```rust
150+
use async_std::prelude::*;
151+
use async_std::stream;
152+
153+
let s = stream::from_iter(vec![(1,2), (3,4)]);
154+
155+
let (left, right): (Vec<_>, Vec<_>) = s.unzip().await;
156+
157+
assert_eq!(left, [1, 3]);
158+
assert_eq!(right, [2, 4]);
159+
```
160+
161+
## Added
162+
163+
- Added `Stream::unzip` as "unstable".
164+
- Added verbose errors to the networking types.
165+
166+
## Changed
167+
168+
- Enabled CI on master branch.
169+
- `Future::join` and `Future::try_join` can now join futures with different
170+
output types.
171+
172+
## Fixed
173+
174+
- Fixed the docs and `Debug` output of `BufWriter`.
175+
- Fixed a bug in `Stream::throttle` that made it consume too much CPU.
176+
10177
# [1.1.0] - 2019-11-21
11178

12179
[API Documentation](https://docs.rs/async-std/1.1.0/async-std)
@@ -510,7 +677,11 @@ task::blocking(async {
510677

511678
- Initial beta release
512679

513-
[Unreleased]: https://github.com/async-rs/async-std/compare/v1.1.0...HEAD
680+
[Unreleased]: https://github.com/async-rs/async-std/compare/v1.5.0...HEAD
681+
[1.5.0]: https://github.com/async-rs/async-std/compare/v1.4.0...v1.5.0
682+
[1.4.0]: https://github.com/async-rs/async-std/compare/v1.3.0...v1.4.0
683+
[1.3.0]: https://github.com/async-rs/async-std/compare/v1.2.0...v1.3.0
684+
[1.2.0]: https://github.com/async-rs/async-std/compare/v1.1.0...v1.2.0
514685
[1.1.0]: https://github.com/async-rs/async-std/compare/v1.0.1...v1.1.0
515686
[1.0.1]: https://github.com/async-rs/async-std/compare/v1.0.0...v1.0.1
516687
[1.0.0]: https://github.com/async-rs/async-std/compare/v0.99.12...v1.0.0

Cargo.toml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-std"
3-
version = "1.1.0"
3+
version = "1.5.0"
44
authors = [
55
"Stjepan Glavina <[email protected]>",
66
"Yoshua Wuyts <[email protected]>",
@@ -34,46 +34,48 @@ default = [
3434
"num_cpus",
3535
"pin-project-lite",
3636
]
37-
docs = ["attributes", "unstable"]
38-
unstable = ["default", "broadcaster"]
37+
docs = ["attributes", "unstable", "default"]
38+
unstable = ["std", "broadcaster", "futures-timer"]
3939
attributes = ["async-attributes"]
4040
std = [
41-
"async-macros",
41+
"alloc",
4242
"crossbeam-utils",
43-
"futures-core",
43+
"futures-core/std",
4444
"futures-io",
4545
"memchr",
4646
"once_cell",
47-
"pin-project-lite",
4847
"pin-utils",
4948
"slab",
5049
]
50+
alloc = [
51+
"futures-core/alloc",
52+
"pin-project-lite",
53+
]
5154

5255
[dependencies]
5356
async-attributes = { version = "1.1.1", optional = true }
54-
async-macros = { version = "2.0.0", optional = true }
55-
async-task = { version = "1.0.0", optional = true }
56-
broadcaster = { version = "0.2.6", optional = true, default-features = false, features = ["default-channels"] }
57+
async-task = { version = "1.2.1", optional = true }
58+
broadcaster = { version = "1.0.0", optional = true }
5759
crossbeam-channel = { version = "0.4.0", optional = true }
5860
crossbeam-deque = { version = "0.7.2", optional = true }
5961
crossbeam-utils = { version = "0.7.0", optional = true }
60-
futures-core = { version = "0.3.1", optional = true }
62+
futures-core = { version = "0.3.1", optional = true, default-features = false }
6163
futures-io = { version = "0.3.1", optional = true }
6264
futures-timer = { version = "2.0.2", optional = true }
6365
kv-log-macro = { version = "1.0.4", optional = true }
6466
log = { version = "0.4.8", features = ["kv_unstable"], optional = true }
65-
memchr = { version = "2.2.1", optional = true }
67+
memchr = { version = "2.3.0", optional = true }
6668
mio = { version = "0.6.19", optional = true }
6769
mio-uds = { version = "0.6.7", optional = true }
6870
num_cpus = { version = "1.11.1", optional = true }
6971
once_cell = { version = "1.2.0", optional = true }
70-
pin-project-lite = { version = "0.1.1", optional = true }
72+
pin-project-lite = { version = "0.1.2", optional = true }
7173
pin-utils = { version = "0.1.0-alpha.4", optional = true }
7274
slab = { version = "0.4.2", optional = true }
7375

7476
[dev-dependencies]
7577
femme = "1.3.0"
76-
rand = "0.7.2"
78+
rand = "0.7.3"
7779
surf = "1.0.3"
7880
tempdir = "0.3.7"
7981
futures = "0.3.1"

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,15 @@ syntax.
7474

7575
## Examples
7676

77-
All examples require the [`"attributes"` feature] to be enabled. This feature
78-
is not enabled by default because it significantly impacts compile times. See
79-
[`task::block_on`] for an alternative way to start executing tasks.
80-
8177
```rust
78+
use async_std::task;
79+
8280
async fn say_hello() {
8381
println!("Hello, world!");
8482
}
8583

86-
#[async_std::main]
87-
async fn main() {
88-
say_hello().await;
84+
fn main() {
85+
task::block_on(say_hello())
8986
}
9087
```
9188

@@ -94,7 +91,7 @@ More examples, including networking and file access, can be found in our
9491

9592
[`examples`]: https://github.com/async-rs/async-std/tree/master/examples
9693
[documentation]: https://docs.rs/async-std#examples
97-
[`task::block_on`]: task/fn.block_on.html
94+
[`task::block_on`]: https://docs.rs/async-std/*/async_std/task/fn.block_on.html
9895
[`"attributes"` feature]: https://docs.rs/async-std/#features
9996

10097
## Philosophy
@@ -123,6 +120,20 @@ documentation] on how to enable them.
123120
[cargo-add]: https://github.com/killercup/cargo-edit
124121
[features documentation]: https://docs.rs/async-std/#features
125122

123+
## Ecosystem
124+
125+
* [async-tls](https://crates.io/crates/async-tls) — Async TLS/SSL streams using **Rustls**.
126+
127+
* [async-native-tls](https://crates.io/crates/async-native-tls)**Native TLS** for Async. Native TLS for futures and async-std.
128+
129+
* [async-tungstenite](https://crates.io/crates/async-tungstenite) — Asynchronous **WebSockets** for async-std, tokio, gio and any std Futures runtime.
130+
131+
* [Tide](https://crates.io/crates/tide) — Serve the web. A modular **web framework** built around async/await.
132+
133+
* [SQLx](https://crates.io/crates/sqlx) — The Rust **SQL** Toolkit. SQLx is a 100% safe Rust library for Postgres and MySQL with compile-time checked queries.
134+
135+
* [Surf](https://crates.io/crates/surf) — Surf the web. Surf is a friendly **HTTP client** built for casual Rustaceans and veterans alike.
136+
126137
## License
127138

128139
<sup>

docs/src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
- [Clean Shutdown](./tutorial/clean_shutdown.md)
2020
- [Handling Disconnection](./tutorial/handling_disconnection.md)
2121
- [Implementing a Client](./tutorial/implementing_a_client.md)
22-
- [TODO: Async Patterns](./patterns.md)
22+
- [Async Patterns](./patterns.md)
2323
- [TODO: Collected Small Patterns](./patterns/small-patterns.md)
24+
- [Production-Ready Accept Loop](./patterns/accept-loop.md)
2425
- [Security practices](./security/index.md)
2526
- [Security Disclosures and Policy](./security/policy.md)
2627
- [Glossary](./glossary.md)

docs/src/overview/std-and-library-futures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The future defined in the [futures-rs](https://docs.rs/futures/0.3/futures/prelu
1010

1111
It is critical to understand the difference between `std::future::Future` and `futures::future::Future`, and the approach that `async-std` takes towards them. In itself, `std::future::Future` is not something you want to interact with as a user—except by calling `.await` on it. The inner workings of `std::future::Future` are mostly of interest to people implementing `Future`. Make no mistake—this is very useful! Most of the functionality that used to be defined on `Future` itself has been moved to an extension trait called [`FuturesExt`](https://docs.rs/futures/0.3/futures/future/trait.FutureExt.html). From this information, you might be able to infer that the `futures` library serves as an extension to the core Rust async features.
1212

13-
In the same tradition as `futures`, `async-std` re-exports the core `std::future::Future` type. You can actively opt into the extensions provided by the `futures-preview` crate by adding it to your `Cargo.toml` and importing `FuturesExt`.
13+
In the same tradition as `futures`, `async-std` re-exports the core `std::future::Future` type. You can actively opt into the extensions provided by the `futures` crate by adding it to your `Cargo.toml` and importing `FuturesExt`.
1414

1515
## Interfaces and Stability
1616

0 commit comments

Comments
 (0)