0

I want to find out how Borrow works on String from the source code which is implemented by Index<RangeFull> (source code).

It uses str::from_utf8_unchecked(&self.vec). Here is the problem. str::from_utf8_unchecked accepts &[u8] as its argument but &String.vec is a struct defined here. Why can it work? Unsafe? How does unsafe do this?

Vonfry
  • 325
  • 2
  • 15

0 Answers0