Expand description
Some primitives to simplify implementation of structured data output in display mode. Usage example:
use core::fmt::{Display, Formatter, Result as FmtResult};
use cubob::display_struct;
struct Point {
x: i32,
y: i32,
}
struct Line {
a: Point,
b: Point,
}
impl Display for Point {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
display_struct(
f,
&[
(&"x", &self.x),
(&"y", &self.y),
],
)
}
}
impl Display for Line {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
display_struct(
f,
&[
(&"a", &self.a),
(&"b", &self.b),
],
)
}
}
fn main() {
let line = Line{ a: Point{ x: 0, y: 0}, b: Point{ x: 1, y: 1} };
println!("One-line: {}", line);
println!("Prettified: {:#}", line);
}Structs
Lets to output key-value pair regarding the propagated value of output alternativeness.
Lets to output some listed data regarding the propagated value of output alternativeness.
Lets to output some structure regarding the propagated value of output alternativeness.
Functions
Performs the whole list output routine from creation of ListShow examplar to finishing.
Performs the whole struct output routine from creation of StructShow examplar to finishing (for example see the module-level documentation).