#Get rid of clone inside .then_some(val.clone()).ok_or(Err(val))

10 messages · Page 1 of 1 (latest)

fierce blade
#

Use an if expression: ```rs
if list.contains(&val) {
Ok(val)
} else {
Err(MyError::NumMissing(val))
}

sinful trench
#

Yeah, I just thought about that

#

I thought too much about complex solutions and didn't realize it's actually easy lol

forest ledge
#

then_some was a mistake ferrisPensive

fierce blade
#

why does that function take ownership of val though? I feel like it might be simpler if it just accepted an &str

sinful trench
fierce blade
sinful trench
#

Makes sense

fierce blade
#

but if it is hot, then consider taking ownership overall

sinful trench
#

Nah, you're right