@@ -20,22 +20,13 @@ use core::str;
2020///
2121/// ```rust
2222/// use url::Url;
23- /// # use url::ParseError;
24- /// # #[derive(Debug)]
25- /// # /// A simple wrapper error struct for `no_std` support
26- /// # struct TestError;
27- /// # impl From<ParseError> for TestError {
28- /// # fn from(value: ParseError) -> Self {
29- /// # TestError {}
30- /// # }
31- /// # }
32- /// # impl From<&str> for TestError {
33- /// # fn from(value: &str) -> Self {
34- /// # TestError {}
35- /// # }
36- /// # }
3723///
38- /// # fn run() -> Result<(), TestError> {
24+ /// # #[cfg(feature = "std")]
25+ /// # use std::error::Error;
26+ /// # #[cfg(not(feature = "std"))]
27+ /// # use core::error::Error;
28+ ///
29+ /// # fn run() -> Result<(), Box<dyn Error>> {
3930/// let mut url = Url::parse("mailto:me@example.com")?;
4031/// assert!(url.path_segments_mut().is_err());
4132///
@@ -92,22 +83,13 @@ impl<'a> PathSegmentsMut<'a> {
9283 ///
9384 /// ```rust
9485 /// use url::Url;
95- /// # use url::ParseError;
96- /// # #[derive(Debug)]
97- /// # /// A simple wrapper error struct for `no_std` support
98- /// # struct TestError;
99- /// # impl From<ParseError> for TestError {
100- /// # fn from(value: ParseError) -> Self {
101- /// # TestError {}
102- /// # }
103- /// # }
104- /// # impl From<&str> for TestError {
105- /// # fn from(value: &str) -> Self {
106- /// # TestError {}
107- /// # }
108- /// # }
10986 ///
110- /// # fn run() -> Result<(), TestError> {
87+ /// # #[cfg(feature = "std")]
88+ /// # use std::error::Error;
89+ /// # #[cfg(not(feature = "std"))]
90+ /// # use core::error::Error;
91+ ///
92+ /// # fn run() -> Result<(), Box<dyn Error>> {
11193 /// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
11294 /// url.path_segments_mut().map_err(|_| "cannot be base")?
11395 /// .clear().push("logout");
@@ -133,22 +115,13 @@ impl<'a> PathSegmentsMut<'a> {
133115 ///
134116 /// ```rust
135117 /// use url::Url;
136- /// # use url::ParseError;
137- /// # #[derive(Debug)]
138- /// # /// A simple wrapper error struct for `no_std` support
139- /// # struct TestError;
140- /// # impl From<ParseError> for TestError {
141- /// # fn from(value: ParseError) -> Self {
142- /// # TestError {}
143- /// # }
144- /// # }
145- /// # impl From<&str> for TestError {
146- /// # fn from(value: &str) -> Self {
147- /// # TestError {}
148- /// # }
149- /// # }
150118 ///
151- /// # fn run() -> Result<(), TestError> {
119+ /// # #[cfg(feature = "std")]
120+ /// # use std::error::Error;
121+ /// # #[cfg(not(feature = "std"))]
122+ /// # use core::error::Error;
123+ ///
124+ /// # fn run() -> Result<(), Box<dyn Error>> {
152125 /// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
153126 /// url.path_segments_mut().map_err(|_| "cannot be base")?
154127 /// .push("pulls");
@@ -221,22 +194,13 @@ impl<'a> PathSegmentsMut<'a> {
221194 ///
222195 /// ```rust
223196 /// use url::Url;
224- /// # use url::ParseError;
225- /// # #[derive(Debug)]
226- /// # /// A simple wrapper error struct for `no_std` support
227- /// # struct TestError;
228- /// # impl From<ParseError> for TestError {
229- /// # fn from(value: ParseError) -> Self {
230- /// # TestError {}
231- /// # }
232- /// # }
233- /// # impl From<&str> for TestError {
234- /// # fn from(value: &str) -> Self {
235- /// # TestError {}
236- /// # }
237- /// # }
238197 ///
239- /// # fn run() -> Result<(), TestError> {
198+ /// # #[cfg(feature = "std")]
199+ /// # use std::error::Error;
200+ /// # #[cfg(not(feature = "std"))]
201+ /// # use core::error::Error;
202+ ///
203+ /// # fn run() -> Result<(), Box<dyn Error>> {
240204 /// let mut url = Url::parse("https://github.com/")?;
241205 /// let org = "servo";
242206 /// let repo = "rust-url";
@@ -254,22 +218,13 @@ impl<'a> PathSegmentsMut<'a> {
254218 ///
255219 /// ```rust
256220 /// use url::Url;
257- /// # use url::ParseError;
258- /// # #[derive(Debug)]
259- /// # /// A simple wrapper error struct for `no_std` support
260- /// # struct TestError;
261- /// # impl From<ParseError> for TestError {
262- /// # fn from(value: ParseError) -> Self {
263- /// # TestError {}
264- /// # }
265- /// # }
266- /// # impl From<&str> for TestError {
267- /// # fn from(value: &str) -> Self {
268- /// # TestError {}
269- /// # }
270- /// # }
271221 ///
272- /// # fn run() -> Result<(), TestError> {
222+ /// # #[cfg(feature = "std")]
223+ /// # use std::error::Error;
224+ /// # #[cfg(not(feature = "std"))]
225+ /// # use core::error::Error;
226+ ///
227+ /// # fn run() -> Result<(), Box<dyn Error>> {
273228 /// let mut url = Url::parse("https://github.com/servo")?;
274229 /// url.path_segments_mut().map_err(|_| "cannot be base")?
275230 /// .extend(&["..", "rust-url", ".", "pulls"]);
0 commit comments