Skip to content

Instantly share code, notes, and snippets.

@EvanCarroll
Created March 29, 2022 06:52
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/aa239a6ee69c25b77755668919d9ff2f to your computer and use it in GitHub Desktop.
Save EvanCarroll/aa239a6ee69c25b77755668919d9ff2f to your computer and use it in GitHub Desktop.
// 1. Must only say "ClientError::IndexParseError" ONCE.
// 2. Must return Result<usize, ClientError::IndexParseError>
// 3. No nesting blocks
let last_id = document.select("div.cart:nth-child(1)")
.ok()
.and_then(|mut x| x.next() )
.and_then(|x| {
x.attributes
.borrow()
.get("id")
.and_then(|x: &str| Self::get_last_id(x).ok() )
} )
.ok_or( ClientError::IndexParseError )?;
@EvanCarroll
Copy link
Author

pub fn get_last_id(t: &str) -> Result<usize,ClientError> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment