Crates.io | documented |
lib.rs | documented |
version | 0.9.1 |
source | src |
created_at | 2023-06-05 16:40:17.02234 |
updated_at | 2024-11-04 06:38:29.465986 |
description | Derive and attribute macros for accessing your type's documentation at runtime |
homepage | |
repository | https://github.com/cyqsimon/documented |
max_upload_size | |
id | 883170 |
size | 9,516 |
Derive and attribute macros for accessing your type's documentation at runtime
use documented::{Documented, DocumentedFields, DocumentedVariants};
/// Trying is the first step to failure.
#[derive(Documented, DocumentedFields, DocumentedVariants)]
enum AlwaysPlay {
/// And Kb8.
#[allow(dead_code)]
Kb1,
/// But only if you are white.
F6,
}
// Documented
assert_eq!(AlwaysPlay::DOCS, "Trying is the first step to failure.");
// DocumentedFields
assert_eq!(
AlwaysPlay::FIELD_DOCS,
["And Kb8.", "But only if you are white."]
);
assert_eq!(AlwaysPlay::get_field_docs("Kb1"), Ok("And Kb8."));
// DocumentedVariants
assert_eq!(
AlwaysPlay::F6.get_variant_docs(),
"But only if you are white."
);