Struct typedef::TypeDefStable
[-]
[+]
[src]
pub struct TypeDef { // some fields omitted }
Create a TypeDef structure to identify a type and to print its name.
use typedef::{ TypeDef }; let typedef = TypeDef::of::<int>(); assert!(typedef.is::<int>()); assert!(typedef.get_str() == "int");
Methods
impl TypeDef
fn of<T: 'static>() -> TypeDef
Create a TypeDef structure from a type parameter.
use typedef::{ TypeDef }; let typedef = TypeDef::of::<int>();
fn id_of<T: 'static>() -> TypeId
Get TypeId
for specified type directly.
use std::intrinsics::{ TypeId }; use typedef::{ TypeDef }; assert!(TypeDef::id_of::<int>() == TypeId::of::<int>());
fn name_of<T: 'static>() -> &'static str
Get type name for specified type directly.
use typedef::{ TypeDef }; assert_eq!(TypeDef::name_of::<int>(), "int");
fn is<T: 'static>(&self) -> bool
Check if typedef instance matches type.
use typedef::{ TypeDef }; let typedef = TypeDef::of::<int>(); assert!(typedef.is::<int>());
fn get_str(&self) -> &'static str
Get the static &str
for typedef instance.
use typedef::{ TypeDef }; let typedef = TypeDef::of::<int>(); assert!(typedef.get_str() == "int");