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