Skip to content

Commit 752423a

Browse files
committed
[WIP] Modify examples to not call unwrap
1 parent 0dfc893 commit 752423a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,17 @@ impl Url {
267267
/// ```rust
268268
/// use url::Url;
269269
///
270-
/// let base = Url::parse("https://example.net/a/b.html").unwrap();
271-
/// let url = base.join("c.png").unwrap();
270+
/// fn foo() -> Result<(), url::ParseError> {
271+
/// let base = Url::parse("https://example.net/a/b.html")?;
272+
/// let url = base.join("c.png")?;
272273
/// assert_eq!(url.as_str(), "https://example.net/a/c.png"); // Not /a/b.html/c.png
273274
///
274-
/// let base = Url::parse("https://example.net/a/b/").unwrap();
275-
/// let url = base.join("c.png").unwrap();
275+
/// let base = Url::parse("https://example.net/a/b/")?;
276+
/// let url = base.join("c.png")?;
276277
/// assert_eq!(url.as_str(), "https://example.net/a/b/c.png");
278+
///
279+
/// Ok(())
280+
/// }
277281
/// ```
278282
#[inline]
279283
pub fn join(&self, input: &str) -> Result<Url, ::ParseError> {

0 commit comments

Comments
 (0)