Hacker News new | ask | show | jobs
by whytevuhuni 459 days ago
First of all, you're right, it does indeed do different things. The stand-alone variant only accepts irrefutable patterns, hence why it needs an "else" branch.

But just for fun, let's make it compile!

    enum Result<T> {
        Some(T),
    }
    
    use Result::Some;
    
    fn pop() -> Result<u32> {
        Some(42)
    }
    
    fn main() {
        // This doesn't cause a compilation error
        let Some(work) = pop();
    }