Преглед изворни кода

Auto merge of #164 - servo:doctests, r=KiChjang

Enable doctests and correct nearby documentation.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/164)
<!-- Reviewable:end -->
bors-servo пре 10 година
родитељ
комит
9e1e198b4c
1 измењених фајлова са 10 додато и 15 уклоњено
  1. 10 15
      src/lib.rs

+ 10 - 15
src/lib.rs

@@ -405,7 +405,8 @@ impl<'a> UrlParser<'a> {
     ///
     /// The default scheme type mapper is as follows:
     ///
-    /// ```ignore
+    /// ```
+    /// # use url::SchemeType;
     /// fn whatwg_scheme_type_mapper(scheme: &str) -> SchemeType {
     ///     match scheme {
     ///         "file" => SchemeType::FileLike,
@@ -622,13 +623,10 @@ impl Url {
     /// and may give nonsensical results for other schemes.
     /// It is the user’s responsibility to check the URL’s scheme before calling this.
     ///
-    /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path`
-    /// or `std::path::windows::Path`.
-    /// (Use `std::path::Path` to pick one of them depending on the local system.)
-    /// If the compiler can not infer the desired type from context, you may have to specify it:
-    ///
-    /// ```ignore
-    /// let path = url.to_file_path::<std::path::posix::Path>();
+    /// ```
+    /// # use url::Url;
+    /// # let url = Url::parse("file:///etc/passwd").unwrap();
+    /// let path = url.to_file_path();
     /// ```
     ///
     /// Returns `Err` if the host is neither empty nor `"localhost"`,
@@ -963,13 +961,10 @@ impl RelativeSchemeData {
     /// and may give nonsensical results for other schemes.
     /// It is the user’s responsibility to check the URL’s scheme before calling this.
     ///
-    /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path`
-    /// or `std::path::windows::Path`.
-    /// (Use `std::path::Path` to pick one of them depending on the local system.)
-    /// If the compiler can not infer the desired type from context, you may have to specifiy it:
-    ///
-    /// ```ignore
-    /// let path = url.to_file_path::<std::path::posix::Path>();
+    /// ```
+    /// # use url::Url;
+    /// # let url = Url::parse("file:///etc/passwd").unwrap();
+    /// let path = url.to_file_path();
     /// ```
     ///
     /// Returns `Err` if the host is neither empty nor `"localhost"`,