Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(nll)]
- use std::result;
- #[derive(Debug)]
- pub struct Error<'a>(&'a u8);
- pub type Result<'a, T> = result::Result<T, Error<'a>>;
- pub struct Context;
- impl Context {
- pub fn open<'a>(&'a mut self) -> Result<'a, ()> {
- Err(Error(&0))
- }
- pub fn close<'a>(&'a self) -> Result<'a, ()> {
- Err(Error(&0))
- }
- }
- fn bar(ctx : &mut Context) -> Result<()> {
- match ctx.open() { Err(e) => return Err(e), Ok(x) => x };
- let _ = ctx.close();
- Ok(())
- }
- fn main() {
- let mut ctx = Context;
- let res = bar(&mut ctx).unwrap_err();
- println!("{:?}",res);
- }
Add Comment
Please, Sign In to add comment