Debian Codegraph @

third_party/rust/cstr/tests/pass/macro.rs

raw
1 use cstr::cstr;
2 use std::ffi::CStr;
3
4 macro_rules! cstr_expr {
5 ($s:expr) => {
6 cstr!($s)
7 };
8 }
9
10 macro_rules! cstr_literal {
11 ($s:literal) => {
12 cstr!($s)
13 };
14 }
15
16 fn main() {
17 let foo: &'static CStr = cstr_expr!("foo");
18 assert_eq!(foo, CStr::from_bytes_with_nul(b"foo\0").unwrap());
19 let bar: &'static CStr = cstr_literal!("bar");
20 assert_eq!(bar, CStr::from_bytes_with_nul(b"bar\0").unwrap());
21 }