#[macro_export]
macro_rules! non_empty_string {
($s:expr) => {{
const _: () = assert!(!$s.is_empty(), "String cannot be empty");
unsafe { $crate::NonEmptyString::new_unchecked($s.to_string()) }
}};
}
#[cfg(test)]
mod tests {
const NON_EMPTY_STRING: &'static str = "non-empty-string";
#[test]
fn test_const_non_empty_string_macro_valid() {
let s = non_empty_string!(NON_EMPTY_STRING);
assert_eq!(
s,
crate::NonEmptyString::try_from(NON_EMPTY_STRING).unwrap()
);
}
#[test]
fn test_inline_non_empty_string_macro_valid() {
let s = non_empty_string!("Test String");
assert_eq!(s, crate::NonEmptyString::try_from("Test String").unwrap());
}
}