dispatch-lite 0.1.0

Lightweight enum dispatch for trait objects — a minimal alternative to dynamic dispatch with zero-cost abstractions
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 5.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 26.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Blackdragon41282

dispatch-lite

Lightweight enum dispatch for trait objects — a minimal alternative to enum_dispatch with a smaller dependency footprint.

Usage

Apply #[dispatch_lite] to a trait definition:

use dispatch_lite::dispatch_lite;

#[dispatch_lite]
trait Animal {
    fn sound(&self) -> String;
}

struct Dog;
struct Cat;

impl Animal for Dog { fn sound(&self) -> String { "woof".into() } }
impl Animal for Cat { fn sound(&self) -> String { "meow".into() } }

enum Pet { Dog(Dog), Cat(Cat) }

License

MIT OR Apache-2.0