[][src]Trait oxide_auth::frontends::simple::endpoint::OptRegistrar

pub trait OptRegistrar {
    fn opt_ref(&self) -> Option<&dyn Registrar>;
}

Like AsRef<Registrar +'_> but in a way that is expressible.

You are not supposed to need to implement this.

The difference to AsRef 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 AsRef<Trait> actually refers to AsRef<(Trait + 'static). But as_ref should have unsugared signature:

fn opt_ref<'a>(&'a self) -> Option<&'a (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

fn opt_ref(&self) -> Option<&dyn Registrar>

Reference this as a Registrar or Option::None.

Loading content...

Implementors

impl OptRegistrar for Vacant[src]

impl<T: Registrar> OptRegistrar for T[src]

Loading content...