Skip to main content

non_empty_string

Macro non_empty_string 

Source
macro_rules! non_empty_string {
    ($string: expr) => { ... };
}
Available on crate features alloc or std only.
Expand description

Constructs NonEmptyStr from the given string, panicking if it is empty, and then converts it into NonEmptyString.

§Examples

Simple usage:

use non_empty_str::non_empty_string;

let nekit = non_empty_string!("nekit");

Expands to:

use non_empty_str::non_empty_str;

let nekit = non_empty_str!("nekit").to_non_empty_string();

See non_empty_str! for more details.

Panicking if the string is empty:

use non_empty_str::non_empty_string;

let never = non_empty_string!("");