Crate rkyv_typename

source ·
Expand description

Type names for rkyv_dyn.

The goal of TypeName is to avoid allocations if possible. If all you need is the hash of a type name, then there’s no reason to allocate a string to do it.

rkyv_typename provides a derive macro to easily implement TypeName, and has options to easily customize your type’s name.


use rkyv_typename::TypeName;
#[typename = "CoolType"]
struct Example<T>(T);

let mut type_name = String::new();
Example::<i32>::build_type_name(|piece| type_name += piece);
assert_eq!(type_name, "CoolType<i32>");


  • std: Implements TypeName for standard library types (enabled by default)


Derive Macros

  • Derives TypeName for the labeled type.