3 ms·
That is not correct, &Vec is fundamentally different. &str, &[T], and &Path are all "a pair of a pointer and a length," and String, Vec<T>, and PathBuf are all
by steveklabnik 7y ago
That is not correct, &Vec is fundamentally different. &str, &[T], and &Path are all "a pair of a pointer and a length," and String, Vec<T>, and PathBuf are all "a triple of a pointer, a length, and a capacity.".
&Vec<T> is "a pointer to a triple of a pointer, a length, and a capacity."
- baby 7y agoI guess I’m a bit confused sometimes as what you get when you borrow. Sometimes I can borrow, sometimes I need to call .as_slice() or as_path or as_str
- steveklabnik 7y agoYeah, so thanks to “Deref coercion” a &Vec<T> will coerce into a &[T] in many places. That’s probably what you’re seeing.