• barsoap
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    Maybe shouldn’t call the function anything default and also provide it. The std docs say:

    fn count(x: &str) -> usize { x.len() }
    
    assert_eq!(Ok(2).unwrap_or_else(count), 2);
    assert_eq!(Err("foo").unwrap_or_else(count), 3);