Trait documented::DocumentedFields
source · pub trait DocumentedFields {
const FIELD_DOCS: &'static [Option<&'static str>];
// Provided methods
fn get_field_docs<T: AsRef<str>>(
field_name: T
) -> Result<&'static str, Error> { ... }
fn get_field_comment<T: AsRef<str>>(
field_name: T
) -> Result<&'static str, Error> { ... }
}
Expand description
Adds an associated constant FIELD_DOCS
on your type
containing the documentation of its fields, allowing you to access their
documentation at runtime.
This trait and associated derive macro works on structs, enums, and unions.
For enums, you may find DocumentedVariants
more ergonomic to use.
For how to use the derive macro, see DocumentedFields
.
Required Associated Constants§
sourceconst FIELD_DOCS: &'static [Option<&'static str>]
const FIELD_DOCS: &'static [Option<&'static str>]
The static doc comments on each field or variant of this type, indexed by field/variant order.
Provided Methods§
sourcefn get_field_docs<T: AsRef<str>>(field_name: T) -> Result<&'static str, Error>
fn get_field_docs<T: AsRef<str>>(field_name: T) -> Result<&'static str, Error>
Get a field’s documentation using its name.
Note that for structs with anonymous fields (i.e. tuple structs), this
method will always return Error::NoSuchField
. For this case, use
FIELD_DOCS
directly instead.
sourcefn get_field_comment<T: AsRef<str>>(
field_name: T
) -> Result<&'static str, Error>
👎Deprecated since 0.3.0: This function has an inconsistent name. Use DocumentedFields::get_field_docs
instead.
fn get_field_comment<T: AsRef<str>>( field_name: T ) -> Result<&'static str, Error>
DocumentedFields::get_field_docs
instead.Deprecated alias for get_field_docs
.
Object Safety§
This trait is not object safe.