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 replace a capture group using Rust regex?
- How to use regex lookahead in Rust?
- How to match the end of a line in a Rust regex?
- How to escape dots with regex in Rust?
- How to use regex to match a double quote in Rust?
- How to match a URL with a regex in Rust?
- How to convert the keys of a Rust HashMap to a vector?
- How to replace strings using Rust regex?
- How to use captures_iter with regex in Rust?
- How to use regex with bytes in Rust?
See more codes...