From b96776f7b0c0ddfa5d654561ac555911e9c04c09 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 29 Apr 2024 16:21:45 +0200 Subject: [PATCH] Create const Config::new() function --- src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a887c5e..e0d2961 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -510,10 +510,9 @@ impl Config { _ => (c, c.width().unwrap_or(1)), } } -} -impl Default for Config { - fn default() -> Self { + /// Create a new, default config. + pub const fn new() -> Self { Self { cross_gap: true, label_attach: LabelAttach::Middle, @@ -528,6 +527,13 @@ impl Default for Config { } } + +impl Default for Config { + fn default() -> Self { + Self::new() + } +} + #[test] #[should_panic] #[allow(clippy::reversed_empty_ranges)]