url!() { /* proc-macro */ }
Expand description
Generate a new type for a URL
The url!
macro generates a new type that is backed by a Url
from the url
crate. The new
type implements common traits like Display
and TryFrom<&str>
and TryFrom<String>
. The
inner value can be accessed using the get
method.
ยงExample
use typed_fields::url;
url!(BackendUrl);
fn main() -> Result<(), Box<dyn std::error::Error>> {
let url: BackendUrl = "https://api.example.com".try_into()?;
// Do something with the URL...
}