rformat 0.2.0

Runtime formatting library
Documentation
use trait_mux::trait_mux;

use crate::fmt::Custom;
use std::fmt::{Binary, Debug, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex};

/// Trait for types that can be converted to `usize`.
pub trait Usize {
    /// Returns the value as a `usize`.
    fn as_usize(&self) -> usize;
}

impl Usize for usize {
    /// Returns the value as a `usize` (identity for `usize`).
    fn as_usize(&self) -> usize {
        *self
    }
}

trait_mux!(
    /// Struct that can hold any value implementing one or more formatting traits.
    ///
    /// This is generated by the `trait_mux!` macro and supports all standard formatting traits,
    /// as well as the custom `Custom` and `Usize` traits.
    struct Formattable {
        Binary,
        Custom,
        Debug,
        Display,
        LowerExp,
        LowerHex,
        Octal,
        Pointer,
        UpperExp,
        UpperHex,
        Usize,
    };
);