@@ -252,7 +252,7 @@ impl Url {
252252 /// # }
253253 /// # run().unwrap();
254254 /// ```
255- ///
255+ ///
256256 /// # Errors
257257 ///
258258 /// If the function can not parse an absolute URL from the given string,
@@ -315,7 +315,7 @@ impl Url {
315315 /// ```rust
316316 /// use url::Url;
317317 /// # use url::ParseError;
318- ///
318+ ///
319319 /// # fn run() -> Result<(), ParseError> {
320320 /// let base = Url::parse("https://example.net/a/b.html")?;
321321 /// let url = base.join("c.png")?;
@@ -331,7 +331,7 @@ impl Url {
331331 ///
332332 /// # Errors
333333 ///
334- /// If the function can not parse an URL from the given string
334+ /// If the function can not parse an URL from the given string
335335 /// with this URL as the base URL, a [`ParseError`] variant will be returned.
336336 ///
337337 /// [`ParseError`]: enum.ParseError.html
@@ -1177,11 +1177,11 @@ impl Url {
11771177 /// assert_eq!(url.as_str(), "https://example.com/data.csv");
11781178
11791179 /// url.set_fragment(Some("cell=4,1-6,2"));
1180- /// assert_eq!(url.as_str(), "https://example.com/data.csv#cell=4,1-6,2");
1180+ /// assert_eq!(url.as_str(), "https://example.com/data.csv#cell=4,1-6,2");
11811181 /// assert_eq!(url.fragment(), Some("cell=4,1-6,2"));
11821182 ///
11831183 /// url.set_fragment(None);
1184- /// assert_eq!(url.as_str(), "https://example.com/data.csv");
1184+ /// assert_eq!(url.as_str(), "https://example.com/data.csv");
11851185 /// assert!(url.fragment().is_none());
11861186 /// # Ok(())
11871187 /// # }
@@ -1234,7 +1234,7 @@ impl Url {
12341234 /// assert_eq!(url.as_str(), "https://example.com/products");
12351235 ///
12361236 /// url.set_query(Some("page=2"));
1237- /// assert_eq!(url.as_str(), "https://example.com/products?page=2");
1237+ /// assert_eq!(url.as_str(), "https://example.com/products?page=2");
12381238 /// assert_eq!(url.query(), Some("page=2"));
12391239 /// # Ok(())
12401240 /// # }
@@ -1330,12 +1330,12 @@ impl Url {
13301330 /// # fn run() -> Result<(), ParseError> {
13311331 /// let mut url = Url::parse("https://example.com")?;
13321332 /// url.set_path("api/comments");
1333- /// assert_eq!(url.as_str(), "https://example.com/api/comments");
1333+ /// assert_eq!(url.as_str(), "https://example.com/api/comments");
13341334 /// assert_eq!(url.path(), "/api/comments");
13351335 ///
13361336 /// let mut url = Url::parse("https://example.com/api")?;
13371337 /// url.set_path("data/report.csv");
1338- /// assert_eq!(url.as_str(), "https://example.com/data/report.csv");
1338+ /// assert_eq!(url.as_str(), "https://example.com/data/report.csv");
13391339 /// assert_eq!(url.path(), "/data/report.csv");
13401340 /// # Ok(())
13411341 /// # }
@@ -1496,7 +1496,7 @@ impl Url {
14961496 /// ```
14971497 /// use url::Url;
14981498 /// # use url::ParseError;
1499- ///
1499+ ///
15001500 /// # fn run() -> Result<(), ParseError> {
15011501 /// let mut url = Url::parse("foo://example.net")?;
15021502 /// let result = url.set_host(None);
@@ -1512,7 +1512,7 @@ impl Url {
15121512 /// ```
15131513 /// use url::Url;
15141514 /// # use url::ParseError;
1515- ///
1515+ ///
15161516 /// # fn run() -> Result<(), ParseError> {
15171517 /// let mut url = Url::parse("https://example.net")?;
15181518 /// let result = url.set_host(None);
@@ -1528,7 +1528,7 @@ impl Url {
15281528 /// ```
15291529 /// use url::Url;
15301530 /// # use url::ParseError;
1531- ///
1531+ ///
15321532 /// # fn run() -> Result<(), ParseError> {
15331533 /// let mut url = Url::parse("mailto:rms@example.net")?;
15341534 ///
@@ -1838,7 +1838,7 @@ impl Url {
18381838 /// ```
18391839 /// use url::Url;
18401840 /// # use url::ParseError;
1841- ///
1841+ ///
18421842 /// # fn run() -> Result<(), ParseError> {
18431843 /// let mut url = Url::parse("https://example.net")?;
18441844 /// let result = url.set_scheme("foo");
@@ -1855,7 +1855,7 @@ impl Url {
18551855 /// ```
18561856 /// use url::Url;
18571857 /// # use url::ParseError;
1858- ///
1858+ ///
18591859 /// # fn run() -> Result<(), ParseError> {
18601860 /// let mut url = Url::parse("https://example.net")?;
18611861 /// let result = url.set_scheme("foõ");
@@ -1871,7 +1871,7 @@ impl Url {
18711871 /// ```
18721872 /// use url::Url;
18731873 /// # use url::ParseError;
1874- ///
1874+ ///
18751875 /// # fn run() -> Result<(), ParseError> {
18761876 /// let mut url = Url::parse("mailto:rms@example.net")?;
18771877 /// let result = url.set_scheme("https");
@@ -1920,7 +1920,7 @@ impl Url {
19201920 /// ```
19211921 /// # if cfg!(unix) {
19221922 /// use url::Url;
1923- ///
1923+ ///
19241924 /// # fn run() -> Result<(), ()> {
19251925 /// let url = Url::from_file_path("/tmp/foo.txt")?;
19261926 /// assert_eq!(url.as_str(), "file:///tmp/foo.txt");
@@ -1935,6 +1935,7 @@ impl Url {
19351935 /// # run().unwrap();
19361936 /// # }
19371937 /// ```
1938+ #[ cfg( any( unix, windows, target_os="redox" ) ) ]
19381939 pub fn from_file_path < P : AsRef < Path > > ( path : P ) -> Result < Url , ( ) > {
19391940 let mut serialization = "file://" . to_owned ( ) ;
19401941 let host_start = serialization. len ( ) as u32 ;
@@ -1970,6 +1971,7 @@ impl Url {
19701971 ///
19711972 /// Note that `std::path` does not consider trailing slashes significant
19721973 /// and usually does not include them (e.g. in `Path::parent()`).
1974+ #[ cfg( any( unix, windows, target_os="redox" ) ) ]
19731975 pub fn from_directory_path < P : AsRef < Path > > ( path : P ) -> Result < Url , ( ) > {
19741976 let mut url = Url :: from_file_path ( path) ?;
19751977 if !url. serialization . ends_with ( '/' ) {
@@ -2051,6 +2053,7 @@ impl Url {
20512053 /// (That is, if the percent-decoded path contains a NUL byte or,
20522054 /// for a Windows path, is not UTF-8.)
20532055 #[ inline]
2056+ #[ cfg( any( unix, windows, target_os="redox" ) ) ]
20542057 pub fn to_file_path ( & self ) -> Result < PathBuf , ( ) > {
20552058 if let Some ( segments) = self . path_segments ( ) {
20562059 let host = match self . host ( ) {
@@ -2297,6 +2300,7 @@ fn path_to_file_url_segments_windows(path: &Path, serialization: &mut String)
22972300 Ok ( ( host_end, host_internal) )
22982301}
22992302
2303+
23002304#[ cfg( any( unix, target_os = "redox" ) ) ]
23012305fn file_url_segments_to_pathbuf ( host : Option < & str > , segments : str:: Split < char > ) -> Result < PathBuf , ( ) > {
23022306 use std:: ffi:: OsStr ;
0 commit comments