Created
April 8, 2022 07:54
-
-
Save EvanCarroll/2d826bcbea7b39c1a65c638b82bc4f13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Must only say "ClientError::*" ONCE. | |
// 2. Must return Result<usize, ClientError::IndexParseError> | |
// 3. No nesting blocks, according to RustFMT | |
// 4. Can be no unwrap, or try macro | |
//use std::ops::Deref; | |
let services = document | |
.select("ul.info") | |
.ok() | |
.and_then( |mut select| select.nth(1) ) | |
.as_ref() | |
.map( |ndr| ndr.as_node() ) | |
.and_then( |dn| dn.select("li").ok() ) | |
.map( |e| e.map( |e| e.text_contents() ).collect::<Vec<String>>() ) | |
.ok_or(ClientError::DownloadFailed(listing_url.to_owned()))?; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment