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.
- The minimum supported Rust version (MSRV) is now Rust 1.65.
- Add the
std
feature which should be disabled inno_std
environments. - All Cargo features, except
std
, are now disabled by default. Thefull
feature can be used to get the old behavior of supporting all possible derives. - The
TryFrom
,Add
,Sub
,BitAnd
,BitOr
,BitXor
,Not
andNeg
derives now return a dedicated error type instead of a&'static str
on error. - The
FromStr
derive now uses a dedicatedFromStrError
error type instead of generating unique one each time. - The
Display
derive (and otherfmt
-like ones) now uses#[display("...", (<expr>),*)]
syntax instead of#[display(fmt = "...", ("<expr>"),*)]
, and#[display(bound(<bound>))]
instead of#[display(bound = "<bound>")]
. So without the double quotes around the expressions and bounds. - The
DebugCustom
derive is renamed to justDebug
(gated now under a separatedebug
feature), and its semantics were changed to be a superset ofstd
variant ofDebug
. - The
From
derive doesn't deriveFrom<()>
for enum variants without any fields anymore. This feature was removed because it was considered useless in practice. - The
From
derive now uses#[from(<types>)]
instead of#[from(types(<types>))]
and ignores field type itself. - The
Into
derive now uses#[into(<types>)]
instead of#[into(types(<types>))]
and ignores field type itself. - Importing a derive macro now also import its corresponding trait.
- Add support captured identifiers in
Display
derives. So now you can use:#[display(fmt = "Prefix: {field}")]
instead of needing to use#[display(fmt = "Prefix: {}", field)]
- Add
FromStr
derive support for enums that contain variants without fields. If you pass the name of the variant tofrom_str
it will create the matching variant. - Add
#[unwrap(owned, ref, ref_mut)]
attribute for theUnwrap
derive. By using them, it is possible to derive implementations for the reference types as well. (#206) - Add
TryUnwrap
derive similar to theUnwrap
derive. This one returns aResult
and does not panic. (#206) - Add support for container format in
Debug
derive with the same syntax asDisplay
derives. (#279)
- The
Constructor
andIsVariant
derives now generateconst fn
functions. - The
Unwrap
andIsVariant
derives now generate doc comments. #[automatically_derived]
is now emitted from all macro expansions. This should prevent code style linters from attempting to modify the generated code.- Upgrade to
syn
2.0. - The
Error
derive now works in nightlyno_std
environments when enabling#![feature(error_in_core)]
.
- Use a deterministic
HashSet
in all derives, this is needed for rust analyzer to work correctly. - Use
Provider
API for backtraces inError
derive. - Fix
Error
derive not working withconst
generics. - Support trait objects for source in Error, e.g.
Box<dyn Error + Send + 'static>
From
supports additional types for conversion:#[from(types(u8, u16))]
.
- When specifying specific features of the crate to only enable specific
derives, the
extra-traits
feature ofsyn
is not always enabled when those the specified features do not require it. This should speed up compile time ofsyn
when this feature is not needed.
- Fix generic derives for
MulAssign
- Make sure output of derives is deterministic, for better support in rust-analyzer
- Support for deriving
Error
!!! (many thanks to @ffuugoo and @tyranron)
-
Fix generic bounds for
Deref
andDerefMut
withforward
, i.e. putDeref
bound on whole type, so onwhere Box<T>: Deref
instead of onT: Deref
. (#107) -
The
tests
directory is now correctly included in the crate (requested by Debian package maintainers)
Note: This version is yanked, because quickly after release it was found out tests did not run in CI.
- Fix generic bounds for
Deref
andDerefMut
with noforward
, i.e. no bounds are necessary. (#107)
- Hotfix for a regression in allowed
Display
derives using#
flag, such as{:#b}
(#107)
- Hotfix for a regression in allowed
From
derives (#105)
This release is a huge milestone for this library. Lot's of new derives are implemented and a ton of attributes are added for configuration purposes. These attributes will allow future releases to add features/options without breaking backwards compatibility. This is why the next release with breaking changes is planned to be 1.0.0.
- The minimum supported rust version (MSRV) is now Rust 1.36.
- When using in a Rust 2015 crate, you should add
extern crate core
to your code. no_std
feature is removed, the library now supportsno_std
without having to configure any features.
Deref
derives now dereference to the type in the newtype. So if you haveMyBox(Box<i32>)
, dereferencing it will result in aBox<i32>
not ani32
. To get the old behaviour of forwarding the dereference you can add the#[deref(forward)]
attribute on the struct or field.- Derives for
AsRef
,AsMut
,Sum
,Product
,IntoIterator
. - Choosing the field of a struct for which to derive the newtype derive.
- Ignoring variants of enums when deriving
From
, by using#[from(ignore)]
. - Add
#[from(forward)]
attribute forFrom
derives. This forwards thefrom
calls to the fields themselves. So if your field is ani64
you can call from on ani32
and it will work. - Add
#[mul(forward)]
and#[mul_assign(forward)]
, which implementMul
andMulAssign
with the semantics as if they wereAdd
/AddAssign
. - You can use features to cut down compile time of the crate by only compiling the code needed for the derives that you use. (see Cargo.toml for the features, by default they are all on)
- Add
#[into(owned, ref, ref_mut)]
and#[try_into(owned, ref, ref_mut)]
attributes. These cause theInto
andTryInto
derives to also implement derives that return references to the inner fields. - Allow
#[display(fmt="some shared display text for all enum variants {}")]
attribute on enum. - Better bounds inference of
Display
trait.
- Remove dependency on
regex
to cut down compile time. - Use
syn
1.0
- Automatic detection of traits needed for
Display
format strings
- Added
no_std
support
- Suppress
unused_variables
warnings in derives
- Extended Display-like derives to support custom formats
- Updated to
syn
v0.15
- Updated to
syn
v0.14,quote
v0.6 andproc-macro2
v0.4
- Updated to latest version of
syn
andquote
- Changed some URLs in the docs so they were correct on crates.io and docs.rs
- The
Result
type is now referenced in the derives using its absolute path (::std::result::Result
) to make sure that the derives don't accidentally use anotherResult
type that is in scope.
- Allow deriving of
TryInto
- Allow deriving of
Deref
- Allow deriving of
DerefMut
- Allow deriving of
Display
,Binary
,Octal
,LowerHex
,UpperHex
,LowerExp
,UpperExp
,Pointer
- Allow deriving of
Index
- Allow deriving of
IndexMut
- Allow cross crate inlining of derived methods
- Allow deriving of
FromStr
- Updated to latest version of
syn
andquote
- Add
#[allow(missing_docs)]
to the Constructor definition
- Changed code to work with newer version of the
syn
library.
- Deriving
From
,Into
andConstructor
now works for empty structs.
- The
new()
method that is created when derivingConstructor
is now public. This makes it a lot more useful.
- Derives for
Into
,Constructor
andMulAssign
-like
From
is now derived for enum variants with multiple fields.
- Derivations now support generics.
- Lots of docs.
- Derives for
Neg
-like andAddAssign
-like.
From
can now be derived for structs with multiple fields.