You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
894 B
59 lines
894 B
use super::*;
|
|
|
|
/// Enabled `#[derive(Debug)]` on types with fields that are not `Debug`.
|
|
pub struct Opaque<T>(T);
|
|
|
|
impl<T> Opaque<T>
|
|
{
|
|
/// Create a new `Opaque` wrapper around `value`.
|
|
#[inline]
|
|
pub const fn new(value: T) -> Self
|
|
{
|
|
Self(value)
|
|
}
|
|
|
|
/// Consume `Opaque` and get back the inner value.
|
|
#[inline]
|
|
pub fn into(self) -> T
|
|
{
|
|
self.0
|
|
}
|
|
}
|
|
|
|
impl<T> From<T> for Opaque<T>
|
|
{
|
|
fn from(from: T) -> Self
|
|
{
|
|
Self(from)
|
|
}
|
|
}
|
|
|
|
impl<T> std::fmt::Debug for Opaque<T>
|
|
{
|
|
#[inline]
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
|
|
{
|
|
write!(f, "<opaque type>")
|
|
}
|
|
}
|
|
|
|
impl<T> Deref for Opaque<T>
|
|
{
|
|
type Target = T;
|
|
#[inline]
|
|
fn deref(&self) -> &Self::Target
|
|
{
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
|
|
impl<T> DerefMut for Opaque<T>
|
|
{
|
|
#[inline]
|
|
fn deref_mut(&mut self) -> &mut <Self as Deref>::Target
|
|
{
|
|
&mut self.0
|
|
}
|
|
}
|