mod as_ref;
mod display;
mod from;
mod into_ref;
mod try_from;
pub use as_ref::*;
pub use display::*;
pub use from::*;
pub use into_ref::*;
pub use try_from::*;
pub struct Contextual<T, C>(pub T, pub C);
pub trait WithContext {
fn with<C>(&self, context: C) -> Contextual<&Self, C>;
fn into_with<C>(self, context: C) -> Contextual<Self, C>
where
Self: Sized;
}
impl<T: ?Sized> WithContext for T {
fn with<C>(&self, context: C) -> Contextual<&Self, C> {
Contextual(self, context)
}
fn into_with<C>(self, context: C) -> Contextual<Self, C>
where
Self: Sized,
{
Contextual(self, context)
}
}
impl<T, C> std::ops::Deref for Contextual<T, C> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<T, C> std::ops::DerefMut for Contextual<T, C> {
fn deref_mut(&mut self) -> &mut T {
&mut self.0
}
}