Expand description
§shapely-pretty
A pretty-printing library for types implementing the Shapely trait, providing colorful and well-formatted output.
§Features
- Pretty-print any type implementing the
Shapelytrait - Colorful output with ANSI escape codes
- Unique colors for different scalar types based on their Shape hash
- Customizable indentation and formatting
- Dimmed colors for punctuation
- Simple abstraction over ANSI escape codes
§Example
use shapely::Shapely;
use shapely_pretty::PrettyPrinter;
#[derive(Debug, Shapely)]
struct Person {
name: String,
age: u32,
address: Address,
}
#[derive(Debug, Shapely)]
struct Address {
street: String,
city: String,
country: String,
}
let person = Person {
name: "Alice".to_string(),
age: 30,
address: Address {
street: "123 Main St".to_string(),
city: "Wonderland".to_string(),
country: "Imagination".to_string(),
},
};
// Print with default settings
PrettyPrinter::new().print(&person);
// Customize the printer
PrettyPrinter::new()
.with_indent_size(4)
.with_max_depth(3)
.print(&person);§Funding
Thanks to Namespace for providing fast GitHub Actions workers:
§License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Re-exports§
pub use shapely_core;
Structs§
- Color
Generator - A color generator that produces unique colors based on a hash value
- Pretty
Display - Display wrapper for any type that implements Shapely
- Pretty
Printer - A formatter for pretty-printing Shapely types
- RGB
- RGB color representation
Constants§
Traits§
- Shapely
Pretty - Extension trait for Shapely types to easily pretty-print them
Functions§
- write_
bold - Write ANSI bold formatting to the formatter
- write_
dim - Write ANSI dim formatting to the formatter
- write_
italic - Write ANSI italic formatting to the formatter
- write_
reset - Write ANSI reset code to the formatter
- write_
rgb - Write RGB foreground color code to the formatter
- write_
rgb_ bg - Write RGB background color code to the formatter
- write_
underline - Write ANSI underline formatting to the formatter