Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for 1.0.0 release #83

Merged
merged 5 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ jobs:
- name: Build
run: cargo build
- name: Run tests
run: cargo test -- --skip ui_compile_fail
if: matrix.rust-version != '1.37'
run: cargo test --all -- --skip ui_compile_fail
- name: Run compile-fail tests
if: matrix.rust-version == 'stable'
run: cargo test -- ui_compile_fail
- name: Run tests (MSRV)
if: matrix.rust-version == '1.37'
run: cargo test -- --skip ui_compile_fail
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auto_impl"
version = "0.5.0"
version = "1.0.0"
authors = [
"Ashley Mannix <[email protected]>",
"Lukas Kalbertodt <[email protected]>",
Expand All @@ -16,6 +16,10 @@ autotests = true
edition = "2018"
rust-version = "1.37"

[workspace]
members = [
"examples/async_await"
]

[lib]
proc-macro = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ some common smart pointers and closures.

# Usage

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

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

Expand Down
10 changes: 10 additions & 0 deletions examples/async_await/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "auto_impl_async_await_example"
version = "0.0.0"
publish = false
edition = "2018"

[dependencies]
auto_impl = { path = "../../" }
async-trait = "0.1"
async-std = { version = "1", features = ["attributes"] }
32 changes: 32 additions & 0 deletions examples/async_await/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::time::Duration;
use async_std::task;

use async_trait::async_trait;
use auto_impl::auto_impl;

// Note the order of the attributes here:
// `#[async_trait]` must appear first
#[async_trait]
#[auto_impl(&, Box, Arc)]
trait Component {
async fn run(&self);
}

struct WaitABit(Duration);

#[async_trait]
impl Component for WaitABit {
async fn run(&self) {
task::sleep(self.0).await;
}
}

async fn run_async(a: impl Component) {
a.run().await;
}

#[async_std::main]
async fn main() {
// We can treat our `Box<WaitABit>` as an `impl Component` directly
run_async(Box::new(WaitABit(Duration::from_secs(1)))).await;
}