url2/lib.rs
1#![forbid(missing_docs)]
2#![forbid(warnings)]
3#![forbid(unsafe_code)]
4//! Url2: Ergonomic wrapper around the popular url crate
5//!
6//! # Example
7//!
8//! ```rust
9//! #[macro_use]
10//! extern crate url2;
11//!
12//! fn main() {
13//! let mut url = url2!("https://{}/", "example.com");
14//! url.query_unique()
15//! .set_pair("hello", "world")
16//! .set_pair("foo", "bar");
17//!
18//! assert!(url.query_unique_contains_key("hello"));
19//! assert_eq!("bar", url.query_unique_get("foo").unwrap());
20//!
21//! url.query_unique().remove("foo");
22//!
23//! assert_eq!(
24//! "https://example.com/?hello=world",
25//! url.as_str(),
26//! )
27//! }
28//! ```
29
30extern crate url;
31
32mod error;
33pub use crate::error::*;
34
35mod query_unique;
36pub use crate::query_unique::*;
37
38mod url2;
39pub use crate::url2::*;
40
41/// works like the `format!()` macro, but passes the result through Url2::try_parse()
42#[macro_export]
43macro_rules! try_url2 {
44 ($($e:expr),+) => {
45 $crate::Url2::try_parse(&format!($($e),+))
46 };
47 ($($e:expr),+,) => {
48 $crate::Url2::try_parse(&format!($($e),+))
49 };
50}
51
52/// works like the `format!()` macro, but passes the result through Url2::parse()
53#[macro_export]
54macro_rules! url2 {
55 ($($e:expr),+) => {
56 $crate::Url2::parse(&format!($($e),+))
57 };
58 ($($e:expr),+,) => {
59 $crate::Url2::parse(&format!($($e),+))
60 };
61}
62
63/// Everything you need to work with the Url2 library.
64pub mod prelude {
65 // currently, just export everything
66 // at some point, we may be more selective
67 pub use super::*;
68}