Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

One element tuple

  • We can create a one-element tuple by putting a comma after the element, but probably there is not much value in it.
  • It is better to just create a variable holding that single value.
fn main() {
    let thing = ("text",);
    println!("{:?}", thing);
    println!("{}", thing.0);

    let thing = "text";
    println!("{}", thing);
}
("text",)
text
text