reverse ordering back to normal

This commit is contained in:
Dr. Matthias Ratajczak
2022-12-21 12:15:56 +01:00
parent 7567e9409b
commit f77f769726
+3 -5
View File
@@ -29,12 +29,10 @@ impl Extractor {
} }
pub(crate) fn get_departures<'a>(&'a self, html: &'a Html) -> impl Iterator<Item = ElementRef> { pub(crate) fn get_departures<'a>(&'a self, html: &'a Html) -> impl Iterator<Item = ElementRef> {
// `Select` does not implement DoubleEndedIterator, so we need to collect it first let result: Vec<_> = html.select(&self.departure).collect();
let mut result = html.select(&self.departure).collect::<Vec<_>>();
result.reverse();
// we seem to extract the blocks twice with slightly different layout, so we discard half of them // we seem to extract the blocks twice with slightly different layout, so we discard half of them
result.truncate(result.len() / 2); let half = result.len() / 2;
result.into_iter() result.into_iter().take(half)
} }
pub(crate) fn get_transport_line(departure_block: scraper::ElementRef) -> Result<&str> { pub(crate) fn get_transport_line(departure_block: scraper::ElementRef) -> Result<&str> {