Crates.io | typedef |
lib.rs | typedef |
version | 0.3.2 |
source | src |
created_at | 2014-12-06 22:56:03.466711 |
updated_at | 2017-10-24 18:59:12.703436 |
description | Identify, compare types or print type names. |
homepage | |
repository | https://github.com/Nercury/typedef-rs |
max_upload_size | |
id | 471 |
size | 24,230 |
Identify or compare types, get or print type names.
Since Rust 1.0, this library can only display type names on nightly Rust. On stable rust, it falls back to gobbledygook (type identifier) instead of a nice name.
To activate the nice names instead of gobbledygook, configure this library with
features = ["nightly"]
configuration parameter.
use typedef::{ TypeDef };
// type name querying:
assert!(TypeDef::name_of::<i64>() == "i64");
// and also type value:
let typedef = TypeDef::of::<i64>();
assert!(typedef.is::<i64>());
assert!(typedef.get_str() == "i64");
assert!(typedef == TypeDef::of::<i64>());
println!("type is {:?}", typedef);
Put this in your Cargo.toml
:
[dependencies]
typedef = "0.3"
Configure nightly feature on you crate so that cargo argument --features="nightly"
would enable
nightly
feature on the typedef crate:
[features]
nightly = ["typedef/nightly"]
And this in your crate root:
extern crate typedef;
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.