2 ms·
With "Ferris", these six bytes are in your program's read-only data section; the "Ferris" expression actually returns a reference to these six bytes (this refer
by cesarb 10y ago
With "Ferris", these six bytes are in your program's read-only data section; the "Ferris" expression actually returns a reference to these six bytes (this reference is a "fat" pointer, which consists of a word with the address of the first byte and another word with their length, in this case 6).
The String::from("Ferris") method call returns a String. With the String, these six bytes are in the heap; internally, a String is similar to a Vec<u8> (heap-allocated vector of bytes).