Crate named_types
source ·Expand description
This crate provides Named
, a trait that provides a nice core::fmt::Display
able 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_all
to ignore all generic parameters.ignore = ...
to ignore a generic parameter.passthrough = ...
to use theNamed
implementation of a generic parameter. Takes priority over other options.
To configure multiple options repeat the #[named(...)]
attribute.
Feature flags
-
std
(enabled by default) — enablestd
-
alloc
— enablealloc
-
rust-1-70-0
(enabled by default) — MSRV 1.70.0 -
rust-1-66-0
— MSRV 1.66.0 -
rust-1-65-0
— MSRV 1.65.0 -
rust-1-64-0
— MSRV 1.64.0 -
rust-1-63-0
— MSRV 1.63.0 -
rust-1-61-0
— MSRV 1.61.0 -
rust-1-60-0
— MSRV 1.60.0 -
rust-1-59-0
— MSRV 1.59.0 -
rust-1-57-0
— MSRV 1.57.0 -
rust-1-56-0
— MSRV 1.56.0 -
rust-1-55-0
— MSRV 1.55.0 -
rust-1-54-0
— MSRV 1.54.0 -
rust-1-51-0
— 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
- The name of a type
Traits
- Like
core::fmt::Display
orDebug
but for type names and generic type names.
Derive Macros
- Derives the
Named
trait.