mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
fmt: replace two magic numbers with consts
This commit is contained in:
parent
660014e532
commit
45bdca9f16
1 changed files with 5 additions and 4 deletions
|
@ -21,6 +21,10 @@ mod parasplit;
|
|||
const ABOUT: &str = help_about!("fmt.md");
|
||||
const USAGE: &str = help_usage!("fmt.md");
|
||||
const MAX_WIDTH: usize = 2500;
|
||||
const DEFAULT_GOAL: usize = 70;
|
||||
const DEFAULT_WIDTH: usize = 75;
|
||||
// by default, goal is 93% of width
|
||||
const DEFAULT_GOAL_TO_WIDTH_RATIO: usize = 93;
|
||||
|
||||
mod options {
|
||||
pub const CROWN_MARGIN: &str = "crown-margin";
|
||||
|
@ -39,9 +43,6 @@ mod options {
|
|||
pub const FILES: &str = "files";
|
||||
}
|
||||
|
||||
// by default, goal is 93% of width
|
||||
const DEFAULT_GOAL_TO_WIDTH_RATIO: usize = 93;
|
||||
|
||||
pub type FileOrStdReader = BufReader<Box<dyn Read + 'static>>;
|
||||
pub struct FmtOptions {
|
||||
crown: bool,
|
||||
|
@ -103,7 +104,7 @@ impl FmtOptions {
|
|||
let w = (g * 100 / DEFAULT_GOAL_TO_WIDTH_RATIO).max(g + 3);
|
||||
(w, g)
|
||||
}
|
||||
(None, None) => (75, 70),
|
||||
(None, None) => (DEFAULT_WIDTH, DEFAULT_GOAL),
|
||||
};
|
||||
debug_assert!(width >= goal, "GOAL {goal} should not be greater than WIDTH {width} when given {width_opt:?} and {goal_opt:?}.");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue