Skip to content

Commit

Permalink
chore: release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
audunhalland committed Mar 27, 2024
1 parent 531584e commit 9858312
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.7.0] - 2024-03-27
### Changed
- Unimock bumped to 0.6.
- Reworked async support. Rust now has native support for async functions in traits, which means that entrait doesn't need to interact with this in a hacky way anymore.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "entrait"
version = "0.7.0-dev"
version = "0.7.0"
authors = ["Audun Halland <audun.halland@pm.me>"]
edition = "2021"
rust-version = "1.75"
Expand All @@ -15,7 +15,7 @@ default = []
unimock = ["dep:unimock"]

[dependencies]
entrait_macros = { path = "entrait_macros", version = "0.7.0-dev" }
entrait_macros = { path = "entrait_macros", version = "0.7.0" }
implementation = "0.1"
unimock = { version = "0.6.2", optional = true }

Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,22 @@ fn foo<D>(deps: &D) { // <-- private function
}
```

##### `async` support
Zero-cost async works out of the box.
##### async support
Zero-cost, static-dispatch `async` works out of the box[^1].

When dynamic dispatch is needed, for example in combination with `delegate_by=ref`, entrait understands the `#[async_trait]` attribute when applied after the entrait macro.
Entrait will re-apply that macro to the various impl blocks that get generated.
When dynamic dispatch is needed, for example in combination with `delegate_by=ref`, entrait understands the `#[async_trait]` attribute when applied _after_ the entrait macro.
Entrait will re-apply that macro to the various generated impl blocks as needed.

###### async `Send`-ness
Similar to `async_trait`, entrait generates a [Send]-bound on futures by default.
To opt out of the Send bound, pass `?Send` as a macro argument:

```rust
#[entrait(ReturnRc, ?Send)]
async fn return_rc(_deps: impl Any) -> Rc<i32> {
Rc::new(42)
}
```

##### Integrating with other `fn`-targeting macros, and `no_deps`
Some macros are used to transform the body of a function, or generate a body from scratch.
Expand Down Expand Up @@ -613,4 +624,6 @@ While this is a limitation, it is not necessarily a bad one.
One might say that a layered application architecture should never contain cycles.
If you do need recursive algorithms, you could model this as utility functions outside of the entraited APIs of the application.

[^1]: Literally, out of the [Box]! In entrait version 0.7 and newer, asynchronous functions are zero-cost by default.

<!-- cargo-rdme end -->
2 changes: 1 addition & 1 deletion entrait_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "entrait_macros"
version = "0.7.0-dev"
version = "0.7.0"
authors = ["Audun Halland <audun.halland@pm.me>"]
edition = "2021"
rust-version = "1.60"
Expand Down

0 comments on commit 9858312

Please sign in to comment.