compris 0.0.11

Composite Primitive Schema (CPS) for Rust
Documentation
use super::{super::annotate::*, macros::*};

use {
    depiction::*,
    std::{fmt, io},
};

//
// Boolean
//

impl_normal! {
    /// Normal boolean variant.
    ///
    /// [Annotations], if present, are *ignored* for the purposes of comparison and hashing.
    Boolean(bool)
}

impl_normal_basic!(Boolean);

impl<AnnotatedT> Depict for Boolean<AnnotatedT> {
    fn depict<WriteT>(&self, writer: &mut WriteT, context: &DepictionContext) -> io::Result<()>
    where
        WriteT: io::Write,
    {
        context.separate(writer)?;
        context.theme.write_symbol(writer, self.inner)
    }
}

impl<AnnotatedT> fmt::Display for Boolean<AnnotatedT> {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Display::fmt(&self.inner, formatter)
    }
}

// Conversions

impl<AnnotatedT> From<&Boolean<AnnotatedT>> for bool {
    fn from(boolean: &Boolean<AnnotatedT>) -> Self {
        boolean.inner
    }
}