mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-22 19:43:06 +00:00
Merge remote-tracking branch 'rust/master' into patch-1
# Conflicts: # Cargo.toml Resolved using theirs.
This commit is contained in:
commit
0d5f2bd31d
2 changed files with 27 additions and 8 deletions
14
Cargo.toml
14
Cargo.toml
|
@ -6,18 +6,18 @@ authors = ["Brian Anderson <banderson@mozilla.com>"]
|
|||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.3"
|
||||
byteorder = "1.0"
|
||||
error-chain = "0.10"
|
||||
toml = "0.4"
|
||||
petgraph = "0.4"
|
||||
clap = "2.0"
|
||||
crossbeam = "0.2"
|
||||
error-chain = "0.10"
|
||||
petgraph = "0.4"
|
||||
rand = "0.3"
|
||||
rayon = "0.7"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
rayon = "0.7"
|
||||
clap = "2.0"
|
||||
url = "1.4.0"
|
||||
toml = "0.4"
|
||||
url = "1.4"
|
||||
|
||||
[build-dependencies]
|
||||
skeptic = "0.9"
|
||||
|
|
21
src/net.md
21
src/net.md
|
@ -41,7 +41,26 @@ fn main() {
|
|||
<a name="ex-url-new-from-base"></a>
|
||||
## Create new URLs from a base URL
|
||||
|
||||
[Write me!](https://github.com/brson/rust-cookbook/issues/35)
|
||||
[![url-badge]][url]
|
||||
```rust
|
||||
extern crate url;
|
||||
|
||||
use url::{ParseError, Url};
|
||||
|
||||
const BASE_GITHUB_URL: &'static str = "https://github.com";
|
||||
|
||||
fn main() {
|
||||
match build_github_url("rust-lang/cargo") {
|
||||
Ok(url) => assert_eq!(url.as_str(), "https://github.com/rust-lang/cargo"),
|
||||
Err(error) => panic!("Errored building url: {}", error),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_github_url(path: &str) -> Result<Url, ParseError> {
|
||||
let base_url = Url::parse(BASE_GITHUB_URL)?;
|
||||
base_url.join(path)
|
||||
}
|
||||
```
|
||||
|
||||
[ex-url-origin]: #ex-url-origin
|
||||
<a name="ex-url-origin"></a>
|
||||
|
|
Loading…
Reference in a new issue