Skip to content

BERADQ/stable-typeid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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,
}

About

rust stable typeid

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages