Skip to content

Commit 5e117d2

Browse files
authored
Merge pull request PacktPublishing#22 from honestlysamuk/patch-1
simplify url retrieval in delayserver
2 parents 04d893c + 5295d8c commit 5e117d2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

delayserver/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ async fn delay(path: web::Path<(u64, String)>) -> impl Responder {
3131

3232
#[actix_web::main]
3333
async fn main() -> std::io::Result<()> {
34-
let args: Vec<String> = env::args().collect();
35-
let url;
36-
if args.len() > 1 {
37-
url = args[1].clone();
38-
} else {
39-
url = String::from("localhost");
40-
}
34+
let url = env::args()
35+
.nth(1)
36+
.unwrap_or_else(|| String::from("localhost"));
37+
4138
println!("{EXPLANATION}");
4239
HttpServer::new(|| {
4340
App::new()

0 commit comments

Comments
 (0)