3 ms·
It's not too important. String is a String-Builder, it is a pointer+length+capacity. &String is thus a pointer to a pointer. The idiomatic solution is to use &
by conradludgate 1y ago
It's not too important. String is a String-Builder, it is a pointer+length+capacity. &String is thus a pointer to a pointer.
The idiomatic solution is to use &str, which is a string-view or string-slice, which is only a pointer+length.
&String can implicit cast to &str via deref-coercion, which means that it's free for APIs to only accept &str. Accepting &str is more correct in the idea that not all strings need to be allocated individually, some might be sliced from a larger string, and losing that generality would be a shame.