enum Stack {
    Item(i32, Box<Stack>),
    Empty,
}

use Stack::{Empty, Item};

impl Stack {
    fn new() -> Self {
        Empty
    }

    fn push(self, v: i32) -> Self {
        Item(v, Box::new(self))
    }

    fn pop(self) -> (Option<i32>, Self) {
        match self {
            Item(v, next) => (Some(v), *next),
            Empty => (None, Empty),
        }
    }
}

fn main() {
    let stack = Stack::new();
    let stack = stack.push(100);
    let stack = stack.push(200);
    let (v, stack) = stack.pop();
    println!("pop: {:?}", v);
}