Expand description
This crate provides Named, a trait that provides a nice core::fmt::Displayable way to
get a types Name. It is similar to core::any::type_name without paths, but should
provide a more sensical name for something like std::io::Error, which would show up
as Error with something like pretty-type-name,
whereas this crate provides the name IoError.
The names for std are given based on the Duck
Test, e.g. core::slice::Iter stays Iter
conflicting with something like core::option::Iter because it behaves like a generic iterator, whereas
std::io::Error does not behave like a generic Error but rather is a specific Error type
for io operations.
Additionally a Named derive macro is provided for deriving the Named trait. This macro
can be configured by attributing a derived type with #[named(...)]. The following options can
be passed to the attribute:
rename = "..."to change the types name.format = "..."to use a custom format string that accepts all non-ignored generic. Overridesrename = "..."parameters to format the types name.ignore_allto ignore all generic parameters.ignore = ...to ignore a generic parameter.passthrough = ...to use theNamedimplementation of a generic parameter. Takes priority over other options.
To configure multiple options repeat the #[named(...)] attribute.
§Feature flags
std(enabled by default) — enablestdalloc— enableallocrust-1-70-0(enabled by default) — MSRV 1.70.0rust-1-66-0(enabled by default) — MSRV 1.66.0rust-1-65-0(enabled by default) — MSRV 1.65.0rust-1-64-0(enabled by default) — MSRV 1.64.0rust-1-63-0(enabled by default) — MSRV 1.63.0rust-1-61-0(enabled by default) — MSRV 1.61.0rust-1-60-0(enabled by default) — MSRV 1.60.0rust-1-59-0(enabled by default) — MSRV 1.59.0rust-1-57-0(enabled by default) — MSRV 1.57.0rust-1-56-0(enabled by default) — MSRV 1.56.0rust-1-55-0(enabled by default) — MSRV 1.55.0rust-1-54-0(enabled by default) — MSRV 1.54.0rust-1-51-0(enabled by default) — MSRV 1.51.0 All versions before 1.51.0 are omitted since this crate depends on const generics which are a 1.51.0 feature
Structs§
- Name
- The name of a type
Traits§
- Named
- Like
core::fmt::DisplayorDebugbut for type names and generic type names.