https://github.com/dev-ardi/HN_aggregator
I have some questions about this:
- General advice of things that could be done better
- why is creating a
reqwest::Clientso slow (7-9ms)? - Having to manually drop tx and rx feels like I've done an anti pattern somewhere
- If I don't call exit(0) the program hangs for a few seconds
I wonder if instead of
while let Ok(story) = rx.recv() {
sorted_stories.push(Pair(story.score.unwrap_or_default(), story.id));
stories.insert(story.id, story);
}
drop(rx);
I could do it in another task (for some reason)
let (sorted_stories, stories) = tokio::spawn(async move {
while let Ok(story) = rx.recv() {
sorted_stories.push(Pair(story.score.unwrap_or_default(), story.id));
stories.insert(story.id, story);
}
(sorted_stories, stories)
})
.await
.unwrap();
I don't know how to get rid of the drop(tx) though (I could use a {} block but that's not what I mean