Macro non_empty_string

Source
macro_rules! non_empty_string {
    ($s:expr) => { ... };
}
Expand description

Creates a NonEmptyString from a string literal at compile time.

This macro ensures that the provided string is not empty at compile time, preventing runtime errors due to empty strings.

§Examples

use non_empty_string::{non_empty_string, NonEmptyString};

let s: NonEmptyString = non_empty_string!("Hello, Rust!");
assert_eq!(s, NonEmptyString::new("Hello, Rust!".to_string()).unwrap());

§Compile-time Failure

If an empty string is provided, this macro will cause a compile-time error.

use non_empty_string::non_empty_string;

let s = non_empty_string!("");