unsized_visitor

Attribute Macro unsized_visitor 

Source
#[unsized_visitor]
Expand description

This is an attribute macro that must be used when implementing a UnsizedVisitor.

It is required to use because a UnsizedVisitor 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.

ยงExamples

use std::fmt;

use musli::Context;
use musli::de::UnsizedVisitor;

struct Visitor;

#[musli::de::unsized_visitor]
impl<'de, C> UnsizedVisitor<'de, C, [u8]> for Visitor
where
    C: Context,
{
    type Ok = ();

    #[inline]
    fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "a reference of bytes"
        )
    }
}