glib

Macro gstr

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

Converts a static string literal into a static nul-terminated string.

The expanded expression has type &'static GStr. This macro will panic if the string literal contains any interior nul-bytes.

ยงExamples

use glib::{gstr, GStr, GString};

const MY_STRING: &GStr = gstr!("Hello");
assert_eq!(MY_STRING.as_bytes_with_nul()[5], 0u8);
let owned: GString = MY_STRING.to_owned();
assert_eq!(MY_STRING, owned);