rustRust null string example
A Rust null string is a string that has a length of zero. It is represented by a double quotation mark with nothing in between.
Example code
let s = "";
println!("{}", s.len());
Output example
0
The code above creates a string s
with nothing in between the double quotation marks. The len()
method is then used to print the length of the string, which is 0.
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...