Skip to content

v0.0.12

Pre-release
Pre-release
Compare
Choose a tag to compare
@cfrantz cfrantz released this 22 Apr 15:58
Eliminate use of nightly feature `min_specialization`.

The `min_specialization` feature is only available in nightly and
doesn't seem to be making progress towards becoming a supported language
feature.

What is necessary to support serde-annotate is to be able to get a
reference to the `dyn Annotate` implementation.  With
`min_specialization`, this was done by implementing a default `Annotate`
for all `T: Serialize` and then specialzing `Annotate` on types with
specific annotators.  This generally worked, but it did cause some
problems around `erased_serde::Serialize` as any type information about
the type was erased.

What is really required to implement annotations is to be able to look
up the Annotators for a given type.  The serde serializer actually helps
with this:  The serialize functions for structs and enums accept a
`name` parameter which is the typename of the item being serialized.
Instead of using `min_specialization`, we build a database mapping
typenames to casting functions that can cast a pointer to the
appropriate `dyn Annotate` reference.

1. Simplify the `Annotate` trait to only include the format and comment
   annotations.
2. Update the derive macro to only implement format/comment.  Use the
   `inventory` crate to register the name to annotator-cast functions.
3. Update tests.

Signed-off-by: Chris Frantz <[email protected]>