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
- the type is
- Syntax:
String: let s = String::from("hello");
String slices are reference to part of a String
let slice = &s[0..3]
;"hello"
are string slices
&'static str