3.2.0 #24
commonsensesoftware
announced in
Announcements
3.2.0
#24
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This release has some minor fixes and quality of life improvements.
Features
Service Decoration
Service decoration was already possible, but required a lot of ceremony to set up. First-class support for service decoration is now provided out of the box. Service decoration occurs when one service needs to decorate an existing service registration and replace it without discarding it. It most cases it would not be possible to properly build back up the registered service to be decorated by the decorator type.
The new API enables you to specify the service being decorated and its new implementation type. The existing registration will be automatically resolved and supplied in the callback that you can use to construct the decorated service.
Additional information and the full example can be found in the Service Decoration section of the user guide.
It is currently not possible to use the
Injectabletrait or#[injectable]attribute macro for service decoration as it would result in infinite recursion. This capability might become possible in the future.Fixes
Fix Conditional
#[inject]Resolution When Using#[cfg_attr]Due to the order of attribute macro resolution, the
#[inject]marker was not properly detected if you conditionally used#[injectable]with a custom constructor function. The workaround was to usecfg_if!for the entire declaration or make sure your constructor function always followed the default naming convention offn new() -> Self. This fix corrects the problem and now allows:Breaking Changes*
There are two behavioral, breaking changes that may affect existing users.
#)println!("{}", ServiceCollection::new());println!("{:#}", ServiceCollection::new());Send + Syncdi::ReforArcdirectly and produced warnings if you weren'tServiceProviderunsafely lied that it wasSend + Sync, which has been removed and is now verified by the compilerThese changes are typically considered a breaking change, but I found them to be fully backward compatible in numerous production use cases. Traits used with the async feature either already had
Send + Syncapplied or adding them was trivial and the correct thing to do anyway. Bumping to a major version would require a major version bump in related crates so I'm attempting a minor version bump first. Please report any issues. I'll yank this version and use a major version bump instead if problems arise.This discussion was created from the release 3.2.0.
Beta Was this translation helpful? Give feedback.
All reactions