1#![deny(missing_docs)]
41
42macro_rules! str_type {
43 ($name:ident) => {
44 impl $name {
45 #[allow(dead_code)]
46 pub(crate) const fn from_str_unchecked(s: &str) -> &$name {
47 unsafe { &*(s as *const str as *const $name) }
49 }
50
51 pub const fn as_str(&self) -> &str {
53 &self.0
54 }
55 }
56
57 impl<'a> TryFrom<&'a str> for &'a $name {
58 type Error = $crate::InvalidUrl;
59
60 fn try_from(s: &'a str) -> Result<Self, Self::Error> {
61 $name::new(s)
62 }
63 }
64
65 str_fmt!($name);
66 };
67}
68
69macro_rules! str_fmt {
71 ($name:ident) => {
72 impl AsRef<str> for $name {
73 fn as_ref(&self) -> &str {
74 self.as_str()
75 }
76 }
77
78 impl std::fmt::Display for $name {
79 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80 f.write_str(self.as_str())
81 }
82 }
83
84 impl std::fmt::Debug for $name {
85 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
86 std::fmt::Debug::fmt(self.as_str(), f)
87 }
88 }
89 };
90}
91
92macro_rules! str_eq {
94 ($name:ident) => {
95 impl PartialEq for $name {
96 fn eq(&self, other: &$name) -> bool {
97 self.as_str() == other.as_str()
98 }
99 }
100
101 impl Eq for $name {}
102
103 impl PartialEq<str> for $name {
104 fn eq(&self, other: &str) -> bool {
105 self.as_str() == other
106 }
107 }
108
109 impl PartialEq<&str> for $name {
110 fn eq(&self, other: &&str) -> bool {
111 self.as_str() == *other
112 }
113 }
114
115 impl PartialEq<$name> for str {
116 fn eq(&self, other: &$name) -> bool {
117 self == other.as_str()
118 }
119 }
120
121 impl PartialEq<$name> for &str {
122 fn eq(&self, other: &$name) -> bool {
123 *self == other.as_str()
124 }
125 }
126
127 impl std::hash::Hash for $name {
128 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
129 self.as_str().hash(state)
130 }
131 }
132
133 impl PartialOrd for $name {
134 fn partial_cmp(&self, other: &$name) -> Option<std::cmp::Ordering> {
135 Some(self.cmp(other))
136 }
137 }
138
139 impl Ord for $name {
140 fn cmp(&self, other: &$name) -> std::cmp::Ordering {
141 self.as_str().cmp(other.as_str())
142 }
143 }
144 };
145}
146
147mod authority;
148mod builder;
149mod chars;
150mod error;
151mod host;
152mod idna;
153mod parse;
154mod path;
155mod query;
156pub mod quoting;
157mod scheme;
158mod url;
159
160pub use crate::authority::{Authority, Port, UserInfo};
161pub use crate::builder::{Builder, Parts};
162pub use crate::error::{ErrorKind, InvalidUrl, InvalidUrlParts};
163pub use crate::host::Host;
164pub use crate::path::{Path, PathAndQuery, Segments};
165pub use crate::query::{Fragment, Query, QueryPairs};
166pub use crate::scheme::Scheme;
167pub use crate::url::Url;
168
169#[cfg(doctest)]
170#[doc = include_str!("../README.md")]
171struct ReadmeDoctests;