[][src]Macro async_coap::uri::uri_ref

macro_rules! uri_ref {
    (unsafe $ S : expr) => { ... };
    ($ S : expr) => { ... };
    () => { ... };
}

Creates a &'static UriRef from a string literal.

Accepts only string constants and literals. The given string MUST be well-formed.

Examples:

let x = uri_ref!("a/b/c?q=foobar#frag");
assert_eq!(x.scheme(),None);
assert_eq!(x.raw_authority(),None);
assert_eq!(x.raw_path(),"a/b/c");
assert_eq!(x.raw_query(),Some("q=foobar"));
assert_eq!(x.raw_fragment(),Some("frag"));
let x = uri_ref!("http://example.com");
assert_eq!(x.scheme(),Some("http"));
assert_eq!(x.raw_authority(),Some("example.com"));
assert_eq!(x.raw_path(),"");
assert_eq!(x.raw_query(),None);
assert_eq!(x.raw_fragment(),None);

Checks for correctness are performed at compile time:

This example deliberately fails to compile
// This will not compile.
let x = uri_ref!("%00 invalid %ff");