All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- #![no_std]
- 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.
- Minimum Supported Rust Version bumped to 1.75.
async
entrait functions will get rewritten to thefn f(..) -> impl Future<Output = ?>
form when appearing in trait definitions, due to the async_fn_in_trait warn-by-default lint.
- Improved interoperability with the
async_trait
macro, for scenarios where dynamic dispatch-delegation is used in combination withasync
. ?Send
argument to the entrait macro, for allowing opt-out ofSend
bounds for theFuture
s generated fromasync
trait methods.
- features
boxed-futures
,use-boxed-futures
anduse-associated-futures
.
- Unimock bumped to 0.5.
- Stop adding lifetimes to trait generic params (#30)
syn
upgraded to version 2.
delegate_by=ref
in favor ofdelegate_by = Borrow
(deprecation of the latter). This encourages usingAsRef
instead ofBorrow
.#[entrait(ref)]
on deep delegation impl blocks.
- Make examples compile out of the box, by selecting the correct features.
- Entrait methods now correctly mirror attributes like
#[cfg]
.
- Feature
async-trait
renamed toboxed-futures
. - Feature
use-async-trait
renamed touse-boxed-futures
. - Feature
use-associated-future
renamed touse-associated-futures
. unimock
optional dependency upgraded to0.4
.- New entrait option
mock_api
to optionally generate a mock setup interface.
entrait_impl
. Replaced by#[entrait] impl TraitImpl for MyType {}
.entrait_dyn_impl
. Replaced by#[entrait(dyn)] impl TraitImpl for MyType {}
.
- Support for
#[entrait] impl TraitImpl for Type {}
for inverted dependencies. Modules will be deprecated in next release, since this is much cleaner.
- Deprecated the recently added
#[entriat_impl]
and#[entrait_dyn_impl]
in favor of the impl block syntax, because that idea didn't yet exist at the time of original implementation.
- Docs: move "Module support" to later in the Introduction section, because it interrupts the original flow of the documentation.
- Dependency inversion support with the
#[entrait(TraitImpl, delegate_by = DelegationTrait)] trait Trait {}
syntax. - #[inline] attribute on small, delegating methods.
- Make zero-cost futures using a separate macro (
entrait::static_async::async_trait
), comparable toasync_trait
.
- Support for using the entrait attribute on a module.
delegate_by = Borrow
option for traits (supports dyn trait leaf dependencies).
- Fix hygiene problem when a parameter has the same ident as the function. Fix uses a hack that appends an underscore to the trait fn param.
- Improved generic params and where clause generation, should generate some fewer tokens overall.
- Doc: Bring back
Impl<T>
impl block code generation example.
- Extract idents from destructured fn params and use those in trait fn signature, given that the ident is unambigous.
- Refactor/optimize internal where clause generator, avoiding syn::parse_quote
implementation
as a dependency, to help users getting started.unimock
feature. Enabling the features downstream will generate mocks upstream.entrait_export
macro andexport
option, for exporting optional mocks from libraries.async-trait
feature for adding a re-export of the async-trait crate.use-async-trait
anduse-associated-future
features for global selection of async strategy.- Support for generic functions.
- Support for entraiting a trait.
- Restructure lib docs.
- Support for parameter-less functions without use of
no_deps
. This is technically 'breaking' but can also be seen as a bugfix. - Submodule import paths (
entrait::unimock
, etc). This is instead enabled by using features.
- Destructured fn params in the original function. Entrait will generate a param name to use in the trait.
- More cargo keywords, categories.
- The implementation of leaf/concrete dependencies now works a bit differently.
Instead of the trait being implemented for some concrete
T
inImpl<T>
,T
is made generic, but with aT: Trait
bound. Because of that, the trait gets implemented a second time: Directly for the concreteT
. This makes it much easier to seamlessly integrate modular apps divided into many crates.
- Every kind of deps parameter that is not recognized as generic is now legal, and interpreted as being concrete.
associated_future
experimental nightly feature, for zero cost futures.
no_deps
support. Add this attribute to not interpret the first parameter as a deps parameter.- default values for config attributes (may skip '= value')
- Bump unimock to 0.2.0, which removes the need for generic assocated types support
- Improve outputted spans to reflect macro arguments instead of input function
- Bump unimock to next major version (0.2.0)
- Support explicit trait visibility, private/inherited by default
- Support for
for T
syntax. The implementations are instead automatically registered with theimplementation
crate.
mockall=test
+unimock=test
support
unimock
support.cfg_attr(test, ...)
mock support.
mock_deps_as
, replaced byunimock
- The
entrait_mock_X
procedural macro for multiple-trait-bound mocking. - The
expand_mock
macro.
- Explicit and opt-in support for
#[async_trait]
withasync_trait = true
. - Support for
mockall
, withmockable = true
. - Support for generating mockall impls for dependencies having multiple trait bounds.
- Remove all cargo features. Specific features are now passed as key/value arguments to the macro.
- Split crate into a regular lib and a proc macro crate.
macro_rules
macros and other library functions go in the "outer"entrait
library.
- Avoid parsing the full
fn
body. The macro only needs to analyze the signature.
- Basic macro with optional async support using
async-trait