#internals #traits #typemap #set #type #iterate #fixed-typemap

fixed_typemap_internals

Internals for the fixed_typemap crate

1 unstable release

0.1.0 Dec 26, 2021

#19 in #internals


Used in fixed_typemap

Unlicense

6KB
59 lines

fixed_typemap

GitHub Actions docs.rs GitHub Sponsors

Implements typemaps that support a lot of extra funcctionality using procedural macros. docs.rs has a lot more than this readme, including a mini-tutorial and worked example. You can use this to:

  • Implement fixed typemaps which don't allocate, and store all their members inline initialized to default values.
  • Use this to implement something like the fields-in-traits proposal, where you "name" fields generically using types.
  • Generate iteration helpers which can iterate over the typemap as trait objects for any number of traits (e.g. this can replace HashMap<TypeId, Box<dyn MyTrait>>, bringing the rest of the functionality along for the ride and also let you do as many traits as you want at once).
  • Add an optional dynamic section which uses a HashMap to enable storing any type.

no_std support is WIP in the sense that it's basically done but I don't know enough to reliably finish it. Doing so shouldn't be hard and I'm very open to contributions which do so and preferrably provide CI configuration.


lib.rs:

Internals for fixed_typemap, a crate for producing typemaps with extended functionality over a set of known types.

This is a set of internal details used by the proc macros, and shouldn't be depended on directly. Instead, depend on and use fixed_typemap as this is probably what you're looking for.

Dependencies

~2MB
~44K SLoC