Erase Ok(()) on fetch

This commit is contained in:
Writtic 2020-06-27 17:58:36 +09:00
parent bcc32e5569
commit d94e80172c
1 changed files with 3 additions and 4 deletions

View File

@ -17,11 +17,10 @@ use smol::Task;
const ROOT: &str = "https://www.rust-lang.org";
/// Fetches the HTML contents of a web page.
async fn fetch(url: String, sender: Sender<String>) -> Result<()> {
async fn fetch(url: String, sender: Sender<String>) {
let body = surf::get(&url).recv_string().await;
let body = body.unwrap_or_default();
sender.send(body).await?;
Ok(())
sender.send(body).await.unwrap();
}
/// Extracts links from a HTML body.
@ -55,7 +54,7 @@ fn main() -> Result<()> {
Some(url) => {
println!("{}", url);
tasks += 1;
Task::spawn(fetch(url, s.clone())).unwrap().detach();
Task::spawn(fetch(url, s.clone())).detach();
}
}
}