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