Skip to content

Commit c6bd3af

Browse files
authored
Merge pull request #83 from auto-impl-rs/cargo/1.0.0
Prepare for 1.0.0 release
2 parents 708a4c5 + 97b8303 commit c6bd3af

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ jobs:
2525
- name: Build
2626
run: cargo build
2727
- name: Run tests
28-
run: cargo test -- --skip ui_compile_fail
28+
if: matrix.rust-version != '1.37'
29+
run: cargo test --all -- --skip ui_compile_fail
2930
- name: Run compile-fail tests
3031
if: matrix.rust-version == 'stable'
3132
run: cargo test -- ui_compile_fail
33+
- name: Run tests (MSRV)
34+
if: matrix.rust-version == '1.37'
35+
run: cargo test -- --skip ui_compile_fail

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "auto_impl"
3-
version = "0.5.0"
3+
version = "1.0.0"
44
authors = [
55
"Ashley Mannix <[email protected]>",
66
"Lukas Kalbertodt <[email protected]>",
@@ -16,6 +16,10 @@ autotests = true
1616
edition = "2018"
1717
rust-version = "1.37"
1818

19+
[workspace]
20+
members = [
21+
"examples/async_await"
22+
]
1923

2024
[lib]
2125
proc-macro = true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ some common smart pointers and closures.
55

66
# Usage
77

8-
This library requires Rust 1.37.0 or newer.
8+
This library requires Rust 1.37.0 or newer. This library doesn't leave any public API in your code.
99

1010
Add `auto_impl` to your `Cargo.toml` and just use it in your crate:
1111

examples/async_await/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "auto_impl_async_await_example"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2018"
6+
7+
[dependencies]
8+
auto_impl = { path = "../../" }
9+
async-trait = "0.1"
10+
async-std = { version = "1", features = ["attributes"] }

examples/async_await/src/main.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use std::time::Duration;
2+
use async_std::task;
3+
4+
use async_trait::async_trait;
5+
use auto_impl::auto_impl;
6+
7+
// Note the order of the attributes here:
8+
// `#[async_trait]` must appear first
9+
#[async_trait]
10+
#[auto_impl(&, Box, Arc)]
11+
trait Component {
12+
async fn run(&self);
13+
}
14+
15+
struct WaitABit(Duration);
16+
17+
#[async_trait]
18+
impl Component for WaitABit {
19+
async fn run(&self) {
20+
task::sleep(self.0).await;
21+
}
22+
}
23+
24+
async fn run_async(a: impl Component) {
25+
a.run().await;
26+
}
27+
28+
#[async_std::main]
29+
async fn main() {
30+
// We can treat our `Box<WaitABit>` as an `impl Component` directly
31+
run_async(Box::new(WaitABit(Duration::from_secs(1)))).await;
32+
}

0 commit comments

Comments
 (0)