Created
April 8, 2022 07:57
-
-
Save EvanCarroll/24dc1b7f058801543d18d890696d8996 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<Vec<String>, ClientError::*> | |
// 3. No nesting blocks or nested closures | |
// 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