Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanCarroll/2d826bcbea7b39c1a65c638b82bc4f13 to your computer and use it in GitHub Desktop.
Save EvanCarroll/2d826bcbea7b39c1a65c638b82bc4f13 to your computer and use it in GitHub Desktop.
// 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