Expand description
§fmtor
See the FmtOr
trait.
§Examples
use fmtor::FmtOr;
let maybe_ref: Option<&()> = None;
assert_eq!(
"Null",
format!("{:p}", maybe_ref.fmt_or("Null"))
);
use fmtor::FmtOr;
struct NullMarker;
impl std::fmt::Display for NullMarker {
fn fmt(&self, out: &mut std::fmt::Formatter) -> std::fmt::Result {
out.write_str("Null")
}
}
let maybe_ref: Option<&u32> = None;
assert_eq!(
"Null",
format!("{:x}", maybe_ref.fmt_or(NullMarker))
);
Structs§
- Maybe
Format - The type returned from
FmtOr::fmt_or_empty
- Maybe
Format Or - The type returned from
FmtOr::fmt_or
- Maybe
Format OrElse - The type returned from
FmtOr::fmt_or_else