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");

Trait Implementations

impl PartialEq for TypeDef

fn eq(&self, other: &TypeDef) -> bool

fn ne(&self, other: &Rhs) -> bool

impl Show for TypeDef

fn fmt(&self, f: &mut Formatter) -> Result

Derived Implementations

impl Copy for TypeDef

impl Clone for TypeDef

fn clone(&self) -> TypeDef

fn clone_from(&mut self, source: &Self)