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 to match a double quote in Rust?
- How to implement PartialEq for a Rust HashMap?
- How to get a capture group using Rust regex?
- How to convert the keys of a Rust HashMap to a vector?
- How to convert Rust bytes to hex?
- How to use non-capturing groups in Rust regex?
- How to use regex with bytes in Rust?
- How to get the last element of a Rust slice?
- How to match the end of a line in a Rust regex?
See more codes...