#![allow(missing_debug_implementations)]
#![doc(hidden)]
#![unstable(feature = "generic_assert_internals", issue = "44838")]
use crate::{
fmt::{Debug, Formatter},
marker::PhantomData,
};
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub struct TryCaptureWithoutDebug;
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub trait TryCaptureGeneric<E, M> {
fn try_capture(&self, to: &mut Capture<E, M>);
}
impl<E> TryCaptureGeneric<E, TryCaptureWithoutDebug> for &Wrapper<&E> {
#[inline]
fn try_capture(&self, _: &mut Capture<E, TryCaptureWithoutDebug>) {}
}
impl<E> Debug for Capture<E, TryCaptureWithoutDebug> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
f.write_str("N/A")
}
}
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub struct TryCaptureWithDebug;
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub trait TryCapturePrintable<E, M> {
fn try_capture(&self, to: &mut Capture<E, M>);
}
impl<E> TryCapturePrintable<E, TryCaptureWithDebug> for Wrapper<&E>
where
E: Printable,
{
#[inline]
fn try_capture(&self, to: &mut Capture<E, TryCaptureWithDebug>) {
to.elem = Some(*self.0);
}
}
impl<E> Debug for Capture<E, TryCaptureWithDebug>
where
E: Printable,
{
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
match self.elem {
None => f.write_str("N/A"),
Some(ref value) => Debug::fmt(value, f),
}
}
}
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub struct Capture<E, M> {
pub elem: Option<E>,
phantom: PhantomData<M>,
}
impl<M, T> Capture<M, T> {
#[inline]
pub const fn new() -> Self {
Self { elem: None, phantom: PhantomData }
}
}
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub struct Wrapper<T>(pub T);
#[unstable(feature = "generic_assert_internals", issue = "44838")]
pub trait Printable: Copy + Debug {}
impl<T> Printable for T where T: Copy + Debug {}