Skip to content

Commit b8d3c15

Browse files
author
bors-servo
authored
Auto merge of #382 - rap2hpoutre:master, r=SimonSapin
add more documentation for errors More documentations for errors. See #319 and #379 _Side question: I don't know how to document errors when a function returns `Result<(), ()>` so I did not document that part. I would be happy to see one example._ <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/382) <!-- Reviewable:end -->
2 parents c478ee4 + 053be60 commit b8d3c15

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/lib.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ impl Url {
281281
/// # }
282282
/// # run().unwrap();
283283
/// ```
284+
///
285+
/// # Errors
286+
///
287+
/// If the function can not parse an absolute URL from the given string,
288+
/// a [`ParseError`] variant will be returned.
289+
///
290+
/// [`ParseError`]: enum.ParseError.html
284291
#[inline]
285292
pub fn parse_with_params<I, K, V>(input: &str, iter: I) -> Result<Url, ::ParseError>
286293
where I: IntoIterator,
@@ -321,6 +328,13 @@ impl Url {
321328
/// # }
322329
/// # run().unwrap();
323330
/// ```
331+
///
332+
/// # Errors
333+
///
334+
/// If the function can not parse an URL from the given string
335+
/// with this URL as the base URL, a [`ParseError`] variant will be returned.
336+
///
337+
/// [`ParseError`]: enum.ParseError.html
324338
#[inline]
325339
pub fn join(&self, input: &str) -> Result<Url, ::ParseError> {
326340
Url::options().base_url(Some(self)).parse(input)
@@ -1455,9 +1469,6 @@ impl Url {
14551469

14561470
/// Change this URL’s host.
14571471
///
1458-
/// If this URL is cannot-be-a-base or there is an error parsing the given `host`,
1459-
/// do nothing and return `Err`.
1460-
///
14611472
/// Removing the host (calling this with `None`)
14621473
/// will also remove any username, password, and port number.
14631474
///
@@ -1531,6 +1542,13 @@ impl Url {
15311542
/// # }
15321543
/// # run().unwrap();
15331544
/// ```
1545+
///
1546+
/// # Errors
1547+
///
1548+
/// If this URL is cannot-be-a-base or there is an error parsing the given `host`,
1549+
/// a [`ParseError`] variant will be returned.
1550+
///
1551+
/// [`ParseError`]: enum.ParseError.html
15341552
pub fn set_host(&mut self, host: Option<&str>) -> Result<(), ParseError> {
15351553
if self.cannot_be_a_base() {
15361554
return Err(ParseError::SetHostOnCannotBeABaseUrl)

0 commit comments

Comments
 (0)