9951 explained code solutions for 126 technologies


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

Edit this code on GitHub