pub trait OptIssuer {
    // Required method
    fn opt_mut(&mut self) -> Option<&mut dyn Issuer>;
}
Expand description

Like AsMut<Issuer +'_> but in a way that is expressible.

You are not supposed to need to implement this.

The difference to AsMut is that the std trait implies the trait lifetime bound be independent of the lifetime of &self. This leads to some annoying implementation constraints, similar to how you can not implement an Iterator<&'_ mut Item> whose items (i.e. next method) borrow the iterator. Only in this case the lifetime trouble is hidden behind the automatically inferred lifetime, as AsMut<Trait> actually refers to AsMut<(Trait + 'static). But opt_mut should have unsugared signature:

fn opt_mut<'a>(&'a mut self) -> Option<&'a mut (Trait + 'a)>

Unfortunately, the + 'a combiner can only be applied to traits, so we need a separate OptX trait for each trait for which we want to make use of such a function, afaik. If you have better ideas, I’ll be grateful for opening an item on the Issue tracker.

Required Methods§

source

fn opt_mut(&mut self) -> Option<&mut dyn Issuer>

Reference this mutably as an Issuer or Option::None.

Implementors§