use std_::marker::PhantomData;
use phantom_variances::*;
use TypeIdentity;
pub trait SelfOps {
const T: VariantPhantom<Self> = PhantomData;
const T_D: VariantDropPhantom<Self> = PhantomData;
#[inline(always)]
fn assert_ty(self, _other: VariantPhantom<Self>) -> Self
where
Self: Sized,
{
self
}
#[inline(always)]
fn assert_ty_ref(&self, _other: VariantPhantom<Self>) -> &Self
where
Self: Sized,
{
self
}
#[inline(always)]
fn assert_ty_mut(&mut self, _other: VariantPhantom<Self>) -> &mut Self
where
Self: Sized,
{
self
}
#[inline(always)]
fn ty_(&self) -> VariantPhantom<Self> {
PhantomData
}
#[inline(always)]
fn ty_d(&self) -> VariantDropPhantom<Self> {
PhantomData
}
#[inline(always)]
fn ty_inv(&self) -> InvariantPhantom<Self> {
PhantomData
}
#[inline(always)]
fn ty_inv_ref(&self) -> InvariantRefPhantom<Self> {
PhantomData
}
fn eq_id(&self, other: &Self) -> bool {
(self as *const Self) == (other as *const Self)
}
#[inline(always)]
fn piped<F, U>(self, f: F) -> U
where
F: FnOnce(Self) -> U,
Self: Sized,
{
f(self)
}
#[inline(always)]
fn piped_ref<'a, F, U>(&'a self, f: F) -> U
where
F: FnOnce(&'a Self) -> U,
{
f(self)
}
#[inline(always)]
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U
where
F: FnOnce(&'a mut Self) -> U,
{
f(self)
}
#[inline(always)]
fn mutated<F>(mut self, f: F) -> Self
where
F: FnOnce(&mut Self),
Self: Sized,
{
f(&mut self);
self
}
#[inline(always)]
fn observe<F>(self, f: F) -> Self
where
F: FnOnce(&Self),
Self: Sized,
{
f(&self);
self
}
#[inline(always)]
fn into_<T>(self, _: VariantPhantom<T>) -> T
where
Self: Into<T>,
{
self.into()
}
#[inline(always)]
fn as_ref_<T: ?Sized>(&self) -> &T
where
Self: AsRef<T>,
{
self.as_ref()
}
#[inline(always)]
fn as_mut_<T: ?Sized>(&mut self) -> &mut T
where
Self: AsMut<T>,
{
self.as_mut()
}
#[inline(always)]
fn drop_(self)
where
Self: Sized,
{
}
#[doc(hidden)]
#[allow(dead_code)]
fn _dummy_generic_method_preventing_trait_object<F>(self: &Self)
where
F: TypeIdentity<Type = Self>,
{
}
}
impl<T: ?Sized> SelfOps for T {}