use core::ops::{Deref, DerefMut};
pub trait FragileTryContainer<T: ?Sized> {
type Ref<'a>: Deref<Target = T> where Self: 'a;
type RefError;
#[must_use]
fn new_container(t: T) -> Self where Self: Sized, T: Sized;
#[must_use]
fn into_inner(self) -> Option<T> where Self: Sized, T: Sized;
fn try_get_ref(&self) -> Result<Self::Ref<'_>, Self::RefError>;
}
pub trait FragileContainer<T: ?Sized>: FragileTryContainer<T> {
#[must_use]
fn get_ref(&self) -> Self::Ref<'_>;
}
pub trait TryContainer<T: ?Sized>: FragileTryContainer<T> {}
pub trait Container<T: ?Sized>: FragileContainer<T> + TryContainer<T> {}
pub trait FragileTryMutContainer<T: ?Sized>: FragileTryContainer<T> {
type RefMut<'a>: DerefMut<Target = T> where Self: 'a;
type RefMutError;
fn try_get_mut(&mut self) -> Result<Self::RefMut<'_>, Self::RefMutError>;
}
pub trait FragileMutContainer<T: ?Sized>: FragileTryMutContainer<T> + FragileContainer<T> {
#[must_use]
fn get_mut(&mut self) -> Self::RefMut<'_>;
}
pub trait TryMutContainer<T: ?Sized>: FragileTryMutContainer<T> + TryContainer<T> {}
pub trait MutContainer<T: ?Sized>: FragileMutContainer<T> + TryMutContainer<T> + Container<T> {}
pub trait BaseContainer<T: ?Sized>: FragileTryContainer<T> {}
impl<T: ?Sized, C: ?Sized + FragileTryContainer<T>> BaseContainer<T> for C {}
pub trait BaseMutContainer<T: ?Sized>: FragileTryMutContainer<T> {}
impl<T: ?Sized, C: ?Sized + FragileTryMutContainer<T>> BaseMutContainer<T> for C {}