Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81eadf8

Browse files
committed
refactor
Use a single version of the COUNT formatter.
1 parent 2c69ea1 commit 81eadf8

3 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/interactive/widgets/entries.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
use crate::interactive::widgets::COUNT;
12
use crate::interactive::{
23
path_of,
34
widgets::{entry_color, EntryMarkMap},
45
DisplayOptions, EntryDataBundle, SortMode,
56
};
67
use chrono::DateTime;
78
use dua::traverse::{EntryData, Tree, TreeIndex};
8-
use human_format;
99
use itertools::Itertools;
10-
use once_cell::sync::Lazy;
1110
use std::time::SystemTime;
1211
use std::{borrow::Borrow, path::Path};
1312
use tui::{
@@ -24,12 +23,6 @@ use tui_react::{
2423
List, ListProps,
2524
};
2625

27-
static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
28-
let mut formatter = human_format::Formatter::new();
29-
formatter.with_decimals(0).with_separator("");
30-
formatter
31-
});
32-
3326
pub struct EntriesProps<'a> {
3427
pub tree: &'a Tree,
3528
pub root: TreeIndex,

src/interactive/widgets/mark.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::interactive::widgets::COUNT;
12
use crate::interactive::{
23
fit_string_graphemes_with_ellipsis, path_of, widgets::entry_color, CursorDirection,
34
};
@@ -6,9 +7,7 @@ use dua::{
67
traverse::{Tree, TreeIndex},
78
ByteFormat,
89
};
9-
use human_format;
1010
use itertools::Itertools;
11-
use once_cell::sync::Lazy;
1211
use std::{
1312
borrow::Borrow,
1413
collections::{btree_map::Entry, BTreeMap},
@@ -28,12 +27,6 @@ use tui_react::{
2827
};
2928
use unicode_segmentation::UnicodeSegmentation;
3029

31-
static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
32-
let mut formatter = human_format::Formatter::new();
33-
formatter.with_decimals(0).with_separator("");
34-
formatter
35-
});
36-
3730
pub enum MarkMode {
3831
Delete,
3932
#[cfg(feature = "trash-move")]

src/interactive/widgets/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ pub use header::*;
1111
pub use help::*;
1212
pub use main::*;
1313
pub use mark::*;
14+
use once_cell::sync::Lazy;
1415

1516
use tui::style::Color;
1617

1718
pub const COLOR_MARKED: Color = Color::Yellow;
1819
pub const COLOR_MARKED_DARK: Color = Color::Rgb(176, 126, 0);
1920

21+
static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
22+
let mut formatter = human_format::Formatter::new();
23+
formatter.with_decimals(0).with_separator("");
24+
formatter
25+
});
26+
2027
fn entry_color(fg: Option<Color>, is_file: bool, is_marked: bool) -> Option<Color> {
2128
match (is_file, is_marked) {
2229
(true, false) => fg,

0 commit comments

Comments
 (0)