637
you are viewing a single comment's thread
view the rest of the comments
[-] barsoap@lemm.ee 1 points 2 years 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);
this post was submitted on 08 Dec 2023
637 points (100.0% liked)

Programmer Humor

37681 readers
404 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS