stable-typeid

Crates.iostable-typeid
lib.rsstable-typeid
version0.0.1
sourcesrc
created_at2024-01-17 07:44:08.705522
updated_at2024-01-17 07:44:08.705522
descriptionGenerate a stable type identifier for rust structs and enums
homepage
repositoryhttps://github.com/BERADQ/stable-typeid
max_upload_size
id1102567
size5,335
Ninnana (BERADQ)

documentation

README

Stable TypeId

Generate a stable type identifier for rust structs and enums

Usage

Use cargo to add this crate to the project dependencies

  cargo add stable-typeid

Demo

use stable_typeid::*;
fn main() {
    let any = MyStruct {
        anything: "Hello TypeId".to_string(),
    };
    foo(&any);
}
fn foo(any: &dyn StableAny) {
    if let Some(my_struct) = any.downcast_ref::<MyStruct>() {
        println!("{} {}", my_struct.anything, MyStruct::_STABLE_ID);
    }
}
#[derive(StableID)]
struct MyStruct {
    anything: String,
}
Commit count: 0

cargo fmt