rustRust null value example
Null values in Rust are represented by the Option
enum. Option
is an enum with two variants, Some
and None
. Some
is used to wrap a value, while None
is used to indicate the absence of a value.
Example code
let x: Option<i32> = None;
This code creates a variable x
of type Option<i32>
and assigns it the value None
. This indicates that x
does not have a value.
Helpful links
Related
More of Rust
- How to match whitespace with a regex in Rust?
- How to match a URL with a regex in Rust?
- How to replace a capture group using Rust regex?
- How to replace all matches using Rust regex?
- How to replace strings using Rust regex?
- How to get an element from a HashSet in Rust?
- How to parse a file with Rust regex?
- How to use 'or' in Rust regex?
- How to use non-capturing groups in Rust regex?
- How to get an entry from a HashSet in Rust?
See more codes...