[go: up one dir, main page]

typeable 0.1.2

Exposes Typeable, for getting TypeIds at runtime.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![deny(missing_docs)]
#![deny(warnings)]

//! Exposes `Typeable`, which exposes the `get_type` method, which gives
//! the `TypeId` of any 'static type.

use std::any::{Any, TypeId};

/// Universal mixin trait for adding a `get_type` method.
///
pub trait Typeable: Any {
    /// Get the `TypeId` of this object.
    #[inline(always)]
    fn get_type(&self) -> TypeId { TypeId::of::<Self>() }
}

impl<T: Any> Typeable for T {}