MCPcopy Index your code
hub / github.com/dtolnay/erased-discriminant

github.com/dtolnay/erased-discriminant @1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.1 ↗ · + Follow
19 symbols 20 edges 2 files 1 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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.

Core symbols most depended-on inside this repo

hash
called by 2
src/lib.rs
of
called by 0
src/lib.rs
small_discriminant
called by 0
src/lib.rs
as_ref
called by 0
src/lib.rs
discriminant_eq
called by 0
src/lib.rs
discriminant_hash
called by 0
src/lib.rs
discriminant_clone
called by 0
src/lib.rs
discriminant_debug
called by 0
src/lib.rs

Shape

Function 9
Method 6
Class 2
Enum 2

Languages

Rust100%

Modules by API surface

src/lib.rs15 symbols
tests/test.rs4 symbols

For agents

$ claude mcp add erased-discriminant \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact