Parcourir la source

docs: Elaborate on error conditions of `set_scheme`

Ben Striegel il y a 6 ans
Parent
commit
d3b36bfac9
1 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. 11 3
      url/src/lib.rs

+ 11 - 3
url/src/lib.rs

@@ -1952,11 +1952,19 @@ impl Url {
 
     /// Change this URL’s scheme.
     ///
-    /// Do nothing and return `Err` if:
+    /// Do nothing and return `Err` under the following circumstances:
     ///
-    /// * The new scheme is not in `[a-zA-Z][a-zA-Z0-9+.-]+`
-    /// * This URL is cannot-be-a-base and the new scheme is one of
+    /// * If the new scheme is not in `[a-zA-Z][a-zA-Z0-9+.-]+`
+    /// * If this URL is cannot-be-a-base and the new scheme is one of
     ///   `http`, `https`, `ws`, `wss`, `ftp`, or `gopher`
+    /// * If either the old or new scheme is `http`, `https`, `ws`,
+    ///   `wss`, `ftp`, or `gopher` and the other is not one of these
+    /// * If the new scheme is `file` and this URL includes credentials
+    ///   or has a non-null port
+    /// * If this URL's scheme is `file` and its host is empty or null
+    ///
+    /// See also [the URL specification's section on legal scheme state
+    /// overrides](https://url.spec.whatwg.org/#scheme-state).
     ///
     /// # Examples
     ///