Pretty Printing
facet-pretty provides colorful, readable pretty-printing for any Facet type. But it can also print the shape itself — showing the structure of your types at compile time. Below we show each value alongside its shape.
Primitives: Integers
Simple numeric types show their value directly, and their shape reveals the underlying primitive type.
Value
42
Shape
Primitives: Floats
Floating-point numbers are displayed with their full precision.
Value
3.141592653589793
Shape
Primitives: Booleans
Boolean values are shown as `true` or `false`.
Value
true
Shape
Primitives: Characters
Character values are displayed with their Unicode representation.
Value
🦀
Shape
Primitives: Strings
String types show their content in quotes.
Value
"Hello, facet!"
Shape
Tuples: Pair
Tuples are displayed with their elements, and the shape shows each element's type.
Value
(f64, u32) (
3.5,
41,
)
Shape
# [ derive ( Facet )]
struct ( …)( f64, u32);
Tuples: Triple
Larger tuples work the same way — each element type is tracked.
Value
(&str, u32, bool) (
"Alice",
30,
true,
)
Shape
# [ derive ( Facet )]
struct ( …)( & T , u32, bool);
Structs: Simple
Struct fields are displayed with their names and values. The shape shows field names, types, and offsets.
Value
Point {
x: 1.5,
y: 2.5,
}
Shape
# [ derive ( Facet )]
struct Point {
x : f64 ,
y : f64 ,
}
Structs: With Optional Fields
Optional fields show `Some(...)` or `None`. The shape includes the full Option type.
Value
Person {
name: "Alice",
age: 30,
email: Option::Some("alice@example.com"),
}
Shape
# [ derive ( Facet )]
struct Person {
name : String ,
age : u32 ,
email : Option < String >,
}
Enums: Unit Variant
Unit variants display just the variant name. The shape shows all possible variants.
Value
Color::Blue
Shape
# [ derive ( Facet )]
# [ repr ( u8 )]
enum Color {
Red ,
Green ,
Blue ,
Rgb ( u8 , u8 , u8 ),
}
Enums: Tuple Variant
Tuple variants show their contained values.
Value
Color::Rgb(
255,
128,
0,
)
Shape
# [ derive ( Facet )]
# [ repr ( u8 )]
enum Color {
Red ,
Green ,
Blue ,
Rgb ( u8 , u8 , u8 ),
}
Enums: Struct Variant
Struct variants display their field names and values.
Value
Message::Move {
x: 10,
y: 20,
}
Shape
# [ derive ( Facet )]
# [ repr ( u8 )]
enum Message {
Quit ,
Move {
x : i32 ,
y : i32 ,
},
Write ( String ),
}
Collections: Vec
Vectors show their elements in a list. The shape describes the element type.
Value
Vec<i32> [1, 2, 3, 4, 5]
Shape
Collections: Array
Fixed-size arrays show their elements. The shape includes the array length.
Value
[u8; 4] [
0a 14 1e 28
]
Shape
Collections: HashMap
Maps display their key-value pairs. The shape describes both key and value types.
Value
HashMap<String, i32> [
"three" => 3,
"one" => 1,
"two" => 2,
]
Shape
Option: Some
Option::Some displays its contained value.
Value
Option::Some("present")
Shape
Option: None
Option::None displays cleanly without the type clutter.
Value
Option::None
Shape
Result: Ok
Result::Ok displays its success value.
Value
unsupported peek variant: Ok(42) (Result<i32, String>, User(Opaque))
Shape
Result: Err
Result::Err displays the error value.
Value
unsupported peek variant: Err("something went wrong") (Result<i32, String>, User(Opaque))
Shape
Nested Structures
Complex nested types are pretty-printed with proper indentation. The shape shows the full type hierarchy.
Value
Company {
name: "Acme Corp",
address: Address {
street: "123 Main St",
city: "Springfield",
zip: "12345",
},
employees: Vec<Person> [
Person {
name: "Alice",
age: 30,
email: Option::Some("alice@acme.com"),
},
Person {
name: "Bob",
age: 25,
email: Option::None,
},
],
}
Shape
# [ derive ( Facet )]
struct Company {
name : String ,
address : Address ,
employees : Vec < Person >,
}
# [ derive ( Facet )]
struct Person {
name : String ,
age : u32 ,
email : Option < String >,
}
# [ derive ( Facet )]
struct Address {
street : String ,
city : String ,
zip : String ,
}