5 releases

Uses old Rust 2015

0.1.4 Nov 26, 2019
0.1.3 Apr 19, 2019
0.1.2 Apr 19, 2019
0.1.1 Dec 4, 2017
0.1.0 Dec 4, 2017

#5 in #typename

Download history 168/week @ 2024-06-21 100/week @ 2024-06-28 90/week @ 2024-07-05 129/week @ 2024-07-12 294/week @ 2024-07-19 155/week @ 2024-07-26 105/week @ 2024-08-02 103/week @ 2024-08-09 94/week @ 2024-08-16 103/week @ 2024-08-23 103/week @ 2024-08-30 89/week @ 2024-09-06 102/week @ 2024-09-13 138/week @ 2024-09-20 123/week @ 2024-09-27 71/week @ 2024-10-04

451 downloads per month
Used in typename

MIT/Apache

7KB

typename

Build Status Latest Version Documentation

A compatible, safe and stable alternative to Rust's std::intrinsics::type_name intrinsic.

DEPRECATION NOTICE: This crate has been deprecated. The type_name intrinsic has been stablized in Rust 1.38. Users of this crate are asked to migrate to std::any::type_name.

Example

extern crate typename;

use typename::TypeName;

fn main() {
    assert_eq!(String::type_name(), "std::string::String");
    assert_eq!(Vec::<i32>::type_name(), "std::vec::Vec<i32>");
    assert_eq!([0, 1, 2].type_name_of(), "[i32; 3]");
}

Contribute

typename is part of the Strymon project:

License

typename is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.


lib.rs:

Procedural macro for deriving the TypeName trait.

Examples

use typename::TypeName;

#[derive(TypeName)]
struct Custom<T: TypeName> {
    some_t: T,
}

fn main() {
    assert_eq!(Custom::<i32>::type_name(), concat!(module_path!(), "::", "Custom<i32>"));
}

Dependencies

~1.5MB
~36K SLoC