Strings & Slices

  • String: let s = String::from("hello");

    • use memory heap
  • String slices are reference to part of a String

    • Syntax: let slice = &s[0..3];
    • String literals: "hello" are string slices
      • the type is &'static str
String in memory