Implement builder pattern

This commit is contained in:
Sharif Haason authored and David Peter committed 2022-10-04 18:09:47 +02:00
1 parent 9bc81820e7
commit 80163764c3
3 files changed
+92 -22

No files matched your search

+10 -11
View File
@@ -1,6 +1,6 @@
use std::io;
use hexyl::{BorderStyle, Printer};
use hexyl::{BorderStyle, PrinterBuilder};
fn main() {
let input = vec![
@@ -16,16 +16,15 @@ fn main() {
let show_position_panel = true;
let use_squeezing = false;
let border_style = BorderStyle::Unicode;
let columns = 2;
let panels = 2;
let mut printer = Printer::new(
&mut handle,
show_color,
show_char_panel,
show_position_panel,
border_style,
use_squeezing,
columns,
);
let mut printer = PrinterBuilder::new(&mut handle)
.show_color(show_color)
.show_char_panel(show_char_panel)
.show_position_panel(show_position_panel)
.with_border_style(border_style)
.with_squeeze(use_squeezing)
.with_panels(panels)
.build();
printer.print_all(&input[..]).unwrap();
}