Crates.io | derive-name |
lib.rs | derive-name |
version | 1.1.0 |
source | src |
created_at | 2023-03-27 17:24:14.859353 |
updated_at | 2023-07-28 12:33:15.024451 |
description | Derive macro to get the name of a struct, enum or enum variant |
homepage | |
repository | https://github.com/abineo-ag/derive-name |
max_upload_size | |
id | 822313 |
size | 5,660 |
Derive macro to get the name of a struct, enum or enum variant.
use derive_name::Name;
#[derive(Name)]
struct Alice;
#[derive(Name)]
enum Bob {}
assert_eq!(Alice::name(), "Alice");
assert_eq!(Bob::name(), "Bob");
use derive_name::Named;
#[derive(derive_name::Name)]
struct Alice;
#[derive(derive_name::Name)]
enum Bob {
Variant
}
let her = Alice {};
let his = Bob::Variant;
assert_eq!(her.name(), "Alice");
assert_eq!(his.name(), "Bob");
use derive_name::VariantName;
#[derive(VariantName)]
enum Alice {
Variant
}
assert_eq!(Alice::Variant.name(), "Variant");
If you think you found a bug: open a issue. Feature request are also welcome.
This library is distributed under the terms of the ISC License.
Find an easy explanation on choosealicense.com/licenses/isc.