Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct Element {
- lol: i32,
- }
- pub struct Container {
- element: Option<Element>,
- }
- pub struct Error {
- text: &'static str,
- }
- fn test<'a, I>(containers: I)
- where
- I: Iterator<Item = Option<&'a Container>>,
- {
- containers.map(|container| {
- let element = container
- .ok_or(Error {
- text: "container not found",
- })?
- .element
- .as_ref()
- .ok_or(Error { text: "no element" })?;
- Ok::<_, Error>(element)
- });
- }
Add Comment
Please, Sign In to add comment