Skip to content

Commit 2bd2af1

Browse files
committed
Merge pull request #308 from frewsxcv/deprecated-example
chore(examples): Stop using deprecated std::os::args in example
2 parents ddb85c4 + 00e46d7 commit 2bd2af1

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/client.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
#![feature(os, io)]
1+
#![feature(env, os, io)]
22
extern crate hyper;
33

4-
use std::os;
4+
use std::env;
55
use std::old_io::stdout;
66
use std::old_io::util::copy;
77

88
use hyper::Client;
99

1010
fn main() {
11-
let args = os::args();
12-
match args.len() {
13-
2 => (),
14-
_ => {
11+
let url = match env::args().nth(1) {
12+
Some(url) => url,
13+
None => {
1514
println!("Usage: client <url>");
1615
return;
1716
}
1817
};
1918

20-
let url = &*args[1];
19+
let url = match url.to_str() {
20+
Some(url) => url,
21+
None => {
22+
println!("Url contains invalid unicode");
23+
return;
24+
}
25+
};
2126

2227
let mut client = Client::new();
2328

0 commit comments

Comments
 (0)