macro_rules! uri {
( unsafe $S:expr ) => { ... };
( $S:expr ) => { ... };
( ) => { ... };
}
Expand description
Creates a &'static Uri
from a string literal.
Accepts only string constants and literals. The given string MUST be well-formed.
Example:
let x = uri!("http://example.com");
assert_eq!(x.scheme(),Some("http"));
assert_eq!(x.raw_authority(),Some("example.com"));
Checks for correctness are performed at compile time:
ⓘ
// This will not compile.
let x = uri!("%00 invalid %ff");
Passing something that is a valid URI-Reference but not a valid URI (i.e.: Missing scheme) will also not compile:
ⓘ
// This will not compile because "a/b/c" isn't a valid URI.
let x = uri!("a/b/c");