Idiomatic way to return Err if an Option is Some

后端 未结 0 1146
情话喂你
情话喂你 2021-01-24 05:21

We can use or_else and ? to return Err early if we encounter None:

let o = None;
let x = o.ok_or(666)?;

But what if we

相关标签:
回答
  • 消灭零回复
提交回复
热议问题