accursed-unutterable-type-id

Crates.ioaccursed-unutterable-type-id
lib.rsaccursed-unutterable-type-id
version0.0.1-pre.ohyes
sourcesrc
created_at2022-06-17 21:05:25.283465
updated_at2023-10-14 21:42:58.025172
descriptionA worse version of std::any::TypeId
homepage
repositoryhttps://github.com/Nilstrieb/accursed-unutterable-type-id
max_upload_size
id608210
size14,807
nora (Noratrieb)

documentation

README

accursed-unutterable-type-id

An accursed, unutterable type id.

Once upon a time, back when time may not have been a human concept but only a vague idea among the wise, there was std::any::TypeId.

It was a good type, and many of these early inhabitants of planet earth were quite fond of it. Yet, there was a fundamental issue in it, that even the elders were not able to resolve: It required significant magic from the compiler. The peoples back then were no stranger to magic, but even just the thought of having magic in their type ids caused numerous wars among them.

After the last and most brutal of the so called "type-id" wars, one especially clever member of one of the leading clans for type id research had a breakthrough. They found a new method to implement type ids in user code! Even though their method had a significant disadvantage in that it had to be implemented using a derive macro (futuristic technology that the elderly have only dreamt of back then). Yet this change was accepted, and peace among the peoples ensured.

Using it is as simple as slapping a derive macro on your type and then getting the type id using AccursedUnutterableTypeId::of.

use accursed_unutterable_type_id::{AccursedUnutterableTypeId, AccursedUnutterablyTypeIdentified};

#[derive(AccursedUnutterablyTypeIdentified)]
struct Uwu;

let type_id = AccursedUnutterableTypeId::of::<Uwu>();
println!("{type_id:?}")
Commit count: 19

cargo fmt