Skip to content

Commit

Permalink
perf: use more const functions
Browse files Browse the repository at this point in the history
This will run on compile time rather than every time on runtime.
  • Loading branch information
EdJoPaTo committed Sep 4, 2023
1 parent 18bc19a commit 0d9d132
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use ratatui::{
widgets::{Block, Borders},
Terminal,
};
use std::{error::Error, io};
use std::error::Error;
use std::io;

use tui_tree_widget::{Tree, TreeItem};

Expand Down Expand Up @@ -74,12 +75,12 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(

let items = Tree::new(app.tree.items.clone())
.block(
Block::default()
Block::new()
.borders(Borders::ALL)
.title(format!("Tree Widget {:?}", app.tree.state)),
)
.highlight_style(
Style::default()
Style::new()
.fg(Color::Black)
.bg(Color::LightGreen)
.add_modifier(Modifier::BOLD),
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> TreeItem<'a> {
{
Self {
text: text.into(),
style: Style::default(),
style: Style::new(),
children: Vec::new(),
}
}
Expand All @@ -205,7 +205,7 @@ impl<'a> TreeItem<'a> {
{
Self {
text: text.into(),
style: Style::default(),
style: Style::new(),
children: children.into(),
}
}
Expand Down Expand Up @@ -300,8 +300,8 @@ impl<'a> Tree<'a> {
items: items.into(),
block: None,
start_corner: Corner::TopLeft,
style: Style::default(),
highlight_style: Style::default(),
style: Style::new(),
highlight_style: Style::new(),
highlight_symbol: "",
node_closed_symbol: "\u{25b6} ", // Arrow to right
node_open_symbol: "\u{25bc} ", // Arrow down
Expand Down

0 comments on commit 0d9d132

Please sign in to comment.