From 078b1174810fa7d69fb256502d60e95a4bd1225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 6 Sep 2025 23:22:38 +0200 Subject: [PATCH] Declare constructor const Permits creating a non-empty string from a string literal at compile time via a const context. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8477b8a..3c4143e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ pub struct NonEmptyString(String); impl NonEmptyString { /// Attempts to create a new `NonEmptyString`. /// If the given `string` is empty, `Err` is returned, containing the original `String`, `Ok` otherwise. - pub fn new(string: String) -> Result { + pub const fn new(string: String) -> Result { if string.is_empty() { Err(string) } else {