You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
891 B
36 lines
891 B
use std::collections::HashSet; |
|
|
|
|
|
const REQUEST_URL: &str = "http://www.pythonchallenge.com/pc/def/linkedlist.php"; |
|
|
|
|
|
fn get_next_nothing(current_nothing: String) -> Result<String, reqwest::Error> |
|
{ |
|
let client = reqwest::blocking::Client::new(); |
|
let resp = client.get(REQUEST_URL) |
|
.query(&[("nothing", current_nothing)]) |
|
.send()?; |
|
|
|
let body = resp.text()?; |
|
let nothing = body.split_ascii_whitespace().last().unwrap(); |
|
Ok(nothing.to_string()) |
|
|
|
} |
|
|
|
fn main() -> Result<(), reqwest::Error> { |
|
|
|
let mut nothings= HashSet::new(); |
|
let mut current_nothing = String::from("12345"); |
|
|
|
|
|
while !nothings.contains(¤t_nothing) |
|
{ |
|
nothings.insert(current_nothing.clone()); |
|
current_nothing = get_next_nothing(current_nothing)?; |
|
println!("Next nothing is: {}",current_nothing); |
|
|
|
} |
|
|
|
println!("{:?}", nothings); |
|
Ok(()) |
|
} |