]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #12231 : wycats/rust/url_path_parse, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 19 Feb 2014 20:51:48 +0000 (12:51 -0800)
committerbors <bors@rust-lang.org>
Wed, 19 Feb 2014 20:51:48 +0000 (12:51 -0800)
It is sometimes useful to parse just the path portion of a URL (path,
query string and fragment) rather than the entire URL.

In theory I could have made Url embed a Path, but that would be a
breaking change and I assume that Servo uses this API. I would be
happy to update the PR to embed Path in Url if that's what people
wanted.

1  2 
src/libextra/url.rs

index c76c73dc4325bcab951ee93374537816927ff10f,580e11b1158740c2d2ec7241eb515bcf0dcf76be..4580dd93098831b4f18d9e19e0e073f70fd3c4fa
@@@ -736,8 -743,17 +775,17 @@@ impl FromStr for Url 
      }
  }
  
+ impl FromStr for Path {
+     fn from_str(s: &str) -> Option<Path> {
+         match path_from_str(s) {
+             Ok(path) => Some(path),
+             Err(_) => None
+         }
+     }
+ }
  /**
 - * Format a `url` as a string
 + * Converts a URL from `Url` to string representation.
   *
   * # Arguments
   *