Trait wyz::fmt::FmtForward[][src]

pub trait FmtForward: Sized {
    fn fmt_binary(self) -> FmtBinary<Self>
    where
        Self: Binary
, { ... }
fn fmt_display(self) -> FmtDisplay<Self>
    where
        Self: Display
, { ... }
fn fmt_lower_exp(self) -> FmtLowerExp<Self>
    where
        Self: LowerExp
, { ... }
fn fmt_lower_hex(self) -> FmtLowerHex<Self>
    where
        Self: LowerHex
, { ... }
fn fmt_octal(self) -> FmtOctal<Self>
    where
        Self: Octal
, { ... }
fn fmt_pointer(self) -> FmtPointer<Self>
    where
        Self: Pointer
, { ... }
fn fmt_upper_exp(self) -> FmtUpperExp<Self>
    where
        Self: UpperExp
, { ... }
fn fmt_upper_hex(self) -> FmtUpperHex<Self>
    where
        Self: UpperHex
, { ... }
fn fmt_list(self) -> FmtList<Self>
    where
        for<'a> &'a Self: IntoIterator
, { ... } }
Expand description

Wraps any value with a format-forward to Debug.

Provided methods

Causes self to use its Binary implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", 3.fmt_binary()),
  "11",
);

Causes self to use its Display implementation when Debug-formatted.

Examples
use wyz::fmt::*;

let text = "hello,
world!";
assert_eq!(
  format!("{:?}", text),
  r#""hello,\nworld!""#,
  // the render contains the sequence U+005C REVERSE SOLIDUS,
  // then U+006E LATIN SMALL LETTER N, *not* U+000A LINE FEED.
);
assert_eq!(
  format!("{:?}", text.fmt_display()),
  "hello,\nworld!",
  // the render does not have wrapping quotes, and
  // the newline is printed directly, not escaped.
);

Causes self to use its LowerExp implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", (31.4).fmt_lower_exp()),
  "3.14e1",
);

Causes self to use its LowerHex implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", 44203.fmt_lower_hex()),
  "acab",
);

Causes self to use its Octal implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", 493.fmt_octal()),
  "755",
);

Causes self to use its Pointer implementation when Debug-formatted.

Examples
use wyz::fmt::*;

let val = 6;
let addr = &val as *const i32;
println!("{:?}", addr.fmt_pointer());
// prints a memory address.

Causes self to use its UpperExp implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", (62.8).fmt_upper_exp()),
  "6.28E1",
);

Causes self to use its UpperHex implementation when Debug-formatted.

Examples
use wyz::fmt::*;

assert_eq!(
  format!("{:?}", 55322.fmt_upper_hex()),
  "D81A",
);

Formats each item in a sequence.

This wrapper structure conditionally implements all of the formatting traits when self can be viewed as an iterator whose items implement them. It iterates over &self and prints each item according to the formatting specifier provided.

Examples
use wyz::fmt::*;

let seq = [10, 20, 30, 40];
assert_eq!(
  format!("{:?}", seq.fmt_list().fmt_lower_hex()),
  "[a, 14, 1e, 28]",
);

Implementors