pub struct BoxCharsBuilder { /* private fields */ }Expand description
Builder for creating custom BoxChars with a fluent, type-safe API.
The builder pattern provides an ergonomic way to construct custom box characters
with method chaining. All methods are const fn where possible for compile-time
evaluation. The builder starts with invisible characters (NONE) and allows
selective customization.
§Design Patterns
§Uniform Styling
Use the convenience methods for consistent appearance:
corners()- Sets all four corners to the same characterhorizontal()- Sets top and bottom bordersvertical()- Sets left and right borders
§Selective Overrides
Start with uniform styling, then override specific positions:
use cli_boxes::BoxChars;
let mixed = BoxChars::builder()
.corners('●') // Set all corners
.horizontal('═') // Set horizontal borders
.vertical('║') // Set vertical borders
.top_left('╔') // Override just top-left
.build();§Asymmetric Designs
Create unique, asymmetric box styles:
use cli_boxes::BoxChars;
let asymmetric = BoxChars::builder()
.top_left('╭').top('─').top_right('╮')
.left('│').right('│')
.bottom_left('└').bottom('─').bottom_right('┘')
.build();§Theme-Based Construction
use cli_boxes::BoxChars;
fn create_theme_box(theme: &str) -> BoxChars {
let mut builder = BoxChars::builder();
match theme {
"minimal" => builder.corners('+').horizontal('-').vertical('|'),
"fancy" => builder.corners('●').horizontal('═').vertical('║'),
"retro" => builder.corners('*').horizontal('=').vertical(':'),
_ => builder.corners('?').horizontal('?').vertical('?'),
}.build()
}§Performance
The builder uses const fn methods where possible, allowing compile-time
evaluation when used with constant inputs. The final build() call is
zero-cost, simply returning the constructed BoxChars struct.
Implementations§
Source§impl BoxCharsBuilder
impl BoxCharsBuilder
Sourcepub const fn horizontal(self, char: char) -> Self
pub const fn horizontal(self, char: char) -> Self
Sets both horizontal border characters (top and bottom) to the same value.
Sourcepub const fn vertical(self, char: char) -> Self
pub const fn vertical(self, char: char) -> Self
Sets both vertical border characters (left and right) to the same value.
Sourcepub const fn bottom_right(self, char: char) -> Self
pub const fn bottom_right(self, char: char) -> Self
Sets the bottom-right corner character.
Sourcepub const fn bottom_left(self, char: char) -> Self
pub const fn bottom_left(self, char: char) -> Self
Sets the bottom-left corner character.
Trait Implementations§
Source§impl Clone for BoxCharsBuilder
impl Clone for BoxCharsBuilder
Source§fn clone(&self) -> BoxCharsBuilder
fn clone(&self) -> BoxCharsBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more