daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub struct Element {
  2.     lol: i32,
  3. }
  4.  
  5. pub struct Container {
  6.     element: Option<Element>,
  7. }
  8.  
  9. pub struct Error {
  10.     text: &'static str,
  11. }
  12.  
  13. fn test<'a, I>(containers: I)
  14. where
  15.     I: Iterator<Item = Option<&'a Container>>,
  16. {
  17.     containers.map(|container| {
  18.         let element = container
  19.             .ok_or(Error {
  20.                 text: "container not found",
  21.             })?
  22.             .element
  23.             .as_ref()
  24.             .ok_or(Error { text: "no element" })?;
  25.  
  26.         Ok::<_, Error>(element)
  27.     });
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top