File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -124,9 +124,14 @@ lazily initialize the default value.
124
124
125
125
The null-forgiving operator (` ! ` ) does not correspond to an equivalent construct
126
126
in Rust, as it only affects the compiler's static flow analysis in C#. In Rust,
127
- there is no need to use a substitute for it.
127
+ there is no need to use a substitute for it. [ ` unwrap ` ] [ opt_unwrap ] is close,
128
+ though: it panics if the value is ` None ` . [ ` expect ` ] [ opt_expect ] is similar but allows
129
+ you to provide a custom error message. Note that as previously said, panics should
130
+ be reserved to unrecoverable situations.
128
131
129
132
[ option ] : https://doc.rust-lang.org/std/option/enum.Option.html
130
133
[ optmap ] : https://doc.rust-lang.org/std/option/enum.Option.html#method.map
131
134
[ opt_and_then ] : https://doc.rust-lang.org/std/option/enum.Option.html#method.and_then
132
135
[ unwrap-or ] : https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrap_or
136
+ [ opt_unwrap ] : https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrap
137
+ [ opt_expect ] : https://doc.rust-lang.org/std/option/enum.Option.html#method.expect
You can’t perform that action at this time.
0 commit comments