impl<T> {{ m.trait_ident }} for ::std::option::Option<T>
where
    T: {{ m.trait_ident }},
{
    {%- for f in m.fields_and_oneof_fields %}
    {%- if f.is_message %}
    type {{ f.ident_camel_unesc }}MessageType<'this> = T::{{ f.ident_camel_unesc }}MessageType<'this> where Self: 'this;
    {%- endif %}

    {%- if f.is_repeated %}

    type {{ f.ident_camel_unesc }}RepeatedType<'this> =
        ::puroro::internal::impls::option::OptionRepeatedField<
            T::{{ f.ident_camel_unesc }}RepeatedType<'this>
        > where Self: 'this;
    fn {{ f.ident }}<'this>(&'this self) -> Self::{{ f.ident_camel_unesc }}RepeatedType<'this> {
        ::puroro::internal::impls::option::OptionRepeatedField::new(self.as_ref().map(|msg| msg.{{ f.ident }}()))
    }

    {%- else %} {#- if f.is_repeated #}

    fn {{ f.ident_unesc }}_opt<'this>(&'this self) -> ::std::option::Option<{{ f.trait_scalar_getter_type }}> {
        self.as_ref().and_then(|msg| msg.{{ f.ident_unesc }}_opt())
    }
    {%- endif %}

    {%- endfor %} {#- for f in m.fields #}
}