@@ -19,26 +19,14 @@ use Url;
19
19
///
20
20
/// ```rust
21
21
/// use url::Url;
22
- /// use std::error::Error;
23
- /// use std::fmt;
24
- ///
25
- /// #[derive(Debug)]
26
- /// struct CannotBeBaseError;
27
- /// impl fmt::Display for CannotBeBaseError {
28
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29
- /// f.write_str(self.description())
30
- /// }
31
- /// }
32
- /// impl Error for CannotBeBaseError {
33
- /// fn description(&self) -> &str { "cannot be a base" }
34
- /// }
22
+ /// # use std::error::Error;
35
23
///
36
24
/// # fn run() -> Result<(), Box<Error>> {
37
25
/// let mut url = Url::parse("mailto:[email protected] ")?;
38
26
/// assert!(url.path_segments_mut().is_err());
39
27
///
40
28
/// let mut url = Url::parse("http://example.net/foo/index.html")?;
41
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
29
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
42
30
/// .pop().push("img").push("2/100%.png");
43
31
/// assert_eq!(url.as_str(), "http://example.net/foo/img/2%2F100%25.png");
44
32
/// # Ok(())
@@ -79,23 +67,11 @@ impl<'a> PathSegmentsMut<'a> {
79
67
///
80
68
/// ```rust
81
69
/// use url::Url;
82
- /// use std::error::Error;
83
- /// use std::fmt;
84
- ///
85
- /// #[derive(Debug)]
86
- /// struct CannotBeBaseError;
87
- /// impl fmt::Display for CannotBeBaseError {
88
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89
- /// f.write_str(self.description())
90
- /// }
91
- /// }
92
- /// impl Error for CannotBeBaseError {
93
- /// fn description(&self) -> &str { "cannot be a base" }
94
- /// }
70
+ /// # use std::error::Error;
95
71
///
96
72
/// # fn run() -> Result<(), Box<Error>> {
97
73
/// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
98
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
74
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
99
75
/// .clear().push("logout");
100
76
/// assert_eq!(url.as_str(), "https://github.com/logout");
101
77
/// # Ok(())
@@ -117,29 +93,17 @@ impl<'a> PathSegmentsMut<'a> {
117
93
/// Example:
118
94
///
119
95
/// ```rust
120
- /// # use url::{Url, ParseError};
121
- /// use std::error::Error;
122
- /// use std::fmt;
123
- ///
124
- /// #[derive(Debug)]
125
- /// struct CannotBeBaseError;
126
- /// impl fmt::Display for CannotBeBaseError {
127
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
128
- /// f.write_str(self.description())
129
- /// }
130
- /// }
131
- /// impl Error for CannotBeBaseError {
132
- /// fn description(&self) -> &str { "cannot be a base" }
133
- /// }
96
+ /// use url::Url;
97
+ /// # use std::error::Error;
134
98
///
135
99
/// # fn run() -> Result<(), Box<Error>> {
136
100
/// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
137
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
101
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
138
102
/// .push("pulls");
139
103
/// assert_eq!(url.as_str(), "https://github.com/servo/rust-url//pulls");
140
104
///
141
105
/// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
142
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
106
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
143
107
/// .pop_if_empty().push("pulls");
144
108
/// assert_eq!(url.as_str(), "https://github.com/servo/rust-url/pulls");
145
109
/// # Ok(())
@@ -194,26 +158,14 @@ impl<'a> PathSegmentsMut<'a> {
194
158
///
195
159
/// ```rust
196
160
/// use url::Url;
197
- /// use std::error::Error;
198
- /// use std::fmt;
199
- ///
200
- /// #[derive(Debug)]
201
- /// struct CannotBeBaseError;
202
- /// impl fmt::Display for CannotBeBaseError {
203
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
204
- /// f.write_str(self.description())
205
- /// }
206
- /// }
207
- /// impl Error for CannotBeBaseError {
208
- /// fn description(&self) -> &str { "cannot be a base" }
209
- /// }
161
+ /// # use std::error::Error;
210
162
///
211
163
/// # fn run() -> Result<(), Box<Error>> {
212
164
/// let mut url = Url::parse("https://github.com/")?;
213
165
/// let org = "servo";
214
166
/// let repo = "rust-url";
215
167
/// let issue_number = "188";
216
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
168
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
217
169
/// .extend(&[org, repo, "issues", issue_number]);
218
170
/// assert_eq!(url.as_str(), "https://github.com/servo/rust-url/issues/188");
219
171
/// # Ok(())
@@ -225,23 +177,11 @@ impl<'a> PathSegmentsMut<'a> {
225
177
///
226
178
/// ```rust
227
179
/// use url::Url;
228
- /// use std::error::Error;
229
- /// use std::fmt;
230
- ///
231
- /// #[derive(Debug)]
232
- /// struct CannotBeBaseError;
233
- /// impl fmt::Display for CannotBeBaseError {
234
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
235
- /// f.write_str(self.description())
236
- /// }
237
- /// }
238
- /// impl Error for CannotBeBaseError {
239
- /// fn description(&self) -> &str { "cannot be a base" }
240
- /// }
180
+ /// # use std::error::Error;
241
181
///
242
182
/// # fn run() -> Result<(), Box<Error>> {
243
183
/// let mut url = Url::parse("https://github.com/servo")?;
244
- /// url.path_segments_mut().map_err(|_| CannotBeBaseError )?
184
+ /// url.path_segments_mut().map_err(|_| "cannot be base" )?
245
185
/// .extend(&["..", "rust-url", ".", "pulls"]);
246
186
/// assert_eq!(url.as_str(), "https://github.com/servo/rust-url/pulls");
247
187
/// # Ok(())
0 commit comments