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 use a custom hash function with a Rust HashMap?
- How to replace strings using Rust regex?
- How to split a string with Rust regex?
- How to yield return in Rust?
- How to calculate the sum of a Rust slice?
- Yield example in Rust
- How to convert a Rust slice to a fixed array?
- How to convert the keys of a Rust HashMap to a vector?
- How to convert a slice of bytes to a string in Rust?
- How to match whitespace with a regex in Rust?
See more codes...