1
0
Fork 0
firefox/third_party/rust/cstr/tests/pass/macro.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

21 lines
434 B
Rust

use cstr::cstr;
use std::ffi::CStr;
macro_rules! cstr_expr {
($s:expr) => {
cstr!($s)
};
}
macro_rules! cstr_literal {
($s:literal) => {
cstr!($s)
};
}
fn main() {
let foo: &'static CStr = cstr_expr!("foo");
assert_eq!(foo, CStr::from_bytes_with_nul(b"foo\0").unwrap());
let bar: &'static CStr = cstr_literal!("bar");
assert_eq!(bar, CStr::from_bytes_with_nul(b"bar\0").unwrap());
}