Should I avoid unwrap in production application?

后端 未结 5 1901
无人及你
无人及你 2020-12-03 13:33

It\'s easy to crash at runtime with unwrap:

fn main() {
    c().unwrap();
}

fn c() -> Option {
    None
}

Resul

5条回答
  •  臣服心动
    2020-12-03 14:29

    unwrap is great for prototyping, but not safe for production. Once you are done with your initial design you go back and replace unwrap() with Result.

提交回复
热议问题