macro_rules! value_vtable {
($type_name:ty, $type_name_fn:expr $(,)?) => { ... };
}Expand description
Creates a ValueVTable for a given type.
This macro generates a ValueVTable with implementations for various traits
(Display, Debug, PartialEq, PartialOrd, Ord, Hash) if they are implemented for the given type.
§Arguments
$type_name:ty- The type for which to create theValueVTable.$type_name_fn:expr- A function that writes the type name to a formatter.
§Example
use facet_core::value_vtable;
use core::fmt::{self, Formatter};
use facet_core::TypeNameOpts;
let vtable = value_vtable!(String, |f: &mut Formatter<'_>, _opts: TypeNameOpts| write!(f, "String"));This cannot be used for a generic type because the impls! thing depends on type bounds.
If you have a generic type, you need to do specialization yourself, like we do for slices,
arrays, etc. — essentially, this macro is only useful for 1) scalars, 2) inside a derive macro