From 45bdca9f167c52fc2681b7484cf4e6705b72d2a5 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 20 Mar 2024 10:23:33 +0100 Subject: [PATCH] fmt: replace two magic numbers with consts --- src/uu/fmt/src/fmt.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 06016f794..b795ad277 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -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>; 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:?}.");