erased-discriminant

Crates.ioerased-discriminant
lib.rserased-discriminant
version
sourcesrc
created_at2024-10-27 21:15:45.275064
updated_at2024-10-27 21:15:45.275064
descriptionType-erased version of core::mem::Discriminant
homepage
repositoryhttps://github.com/dtolnay/erased-discriminant
max_upload_size
id1425012
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Lanthanum (github:zxtn:lanthanum)

documentation

https://docs.rs/erased-discriminant

README

Type-erased Discriminant

github crates.io docs.rs build status

This crate provides a Discriminant type that behaves like core::mem::Discriminant<T> but without the generic type parameter T. With this, we can build collections such as HashSet that contain discriminants from a mixture of different enum types.

use erased_discriminant::Discriminant;
use std::collections::HashSet;

enum Enum {
    A(i32),
    B,
}

enum DifferentEnum {
    A,
}

let mut set = HashSet::new();
set.insert(Discriminant::of(&Enum::A(99)));
set.insert(Discriminant::of(&Enum::B));
set.insert(Discriminant::of(&DifferentEnum::A));
assert_eq!(set.len(), 3);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 37

cargo fmt