#[visitor]
Expand description
This is an attribute macro that must be used when implementing a
Visitor
.
It is required to use because a Visitor
implementation might introduce
new associated types in the future, and this is not yet supported on a
language level in Rust. So this attribute macro polyfills any missing types
automatically.
Note that using derives directly from musli_core
requires you to use the
#[musli_core::visitor(crate = musli_core)]
attribute.
ยงExamples
use std::fmt;
use musli_core::Context;
use musli_core::de::Visitor;
struct AnyVisitor;
#[musli_core::visitor(crate = musli_core)]
impl<'de, C: ?Sized + Context> Visitor<'de, C> for AnyVisitor {
type Ok = ();
#[inline]
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"value that can be decoded into dynamic container"
)
}
}