impl<T> {{ m.trait_ident }} for ::std::option::Option<T>
where
    T: {{ m.trait_ident }},
{
    {%- for field in m.fields %}
    {%- call option_trait_impl_field(field) %}
    {%- endfor %}

    {%- for oneof in m.oneofs %}
    fn {{ oneof.field_ident }}<'this>(&'this self) ->
        Option<
            super::_puroro_nested::{{ m.submodule_ident }}::_puroro_oneofs::{{ oneof.enum_ident }}
            {%- if oneof.has_reference_field %}
            <'this, Self>
            {%- endif %}
        >
    {
        use super::_puroro_nested::{{ m.submodule_ident }}::_puroro_oneofs::{{ oneof.enum_ident }} as E;
        self.as_ref().and_then(|msg| msg.{{ oneof.field_ident }}().map(|oneof| {
            match oneof {
                {%- for field in oneof.fields %}
                E::{{ field.ident }}(v) => E::{{ field.ident }}(v),
                {%- endfor %}
            }
        }))
    }
    {%- endfor %}
}