use crate::{uDebug, uDisplay, uWrite, Formatter};
impl uDebug for bool {
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
if *self {
f.write_str("true")
} else {
f.write_str("false")
}
}
}
impl uDisplay for bool {
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
<bool as uDebug>::fmt(self, f)
}
}
impl uDisplay for char {
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
f.write_char(*self)
}
}
impl<T> uDebug for [T]
where
T: uDebug,
{
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
f.debug_list()?.entries(self)?.finish()
}
}
impl uDisplay for str {
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
f.write_str(self)
}
}
impl<T> uDebug for &'_ T
where
T: uDebug + ?Sized,
{
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
<T as uDebug>::fmt(self, f)
}
}
impl<T> uDisplay for &'_ T
where
T: uDisplay + ?Sized,
{
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
<T as uDisplay>::fmt(self, f)
}
}
impl<T> uDebug for &'_ mut T
where
T: uDebug + ?Sized,
{
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
<T as uDebug>::fmt(self, f)
}
}
impl<T> uDisplay for &'_ mut T
where
T: uDisplay + ?Sized,
{
#[inline(always)]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
<T as uDisplay>::fmt(self, f)
}
}
impl<T> uDebug for Option<T>
where
T: uDebug,
{
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
match self {
None => f.write_str("None"),
Some(x) => f.debug_tuple("Some")?.field(x)?.finish(),
}
}
}
impl<T, E> uDebug for Result<T, E>
where
T: uDebug,
E: uDebug,
{
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
match self {
Err(e) => f.debug_tuple("Err")?.field(e)?.finish(),
Ok(x) => f.debug_tuple("Ok")?.field(x)?.finish(),
}
}
}