Why str is called string slice, if &str is an actual string slice?
Why str is called string slice, if &str is an actual string slice?
Going by the documentation:
str is a "string slice" (primitive type str)[T] is a "slice" (primitive type slice)dyn Trait is a "trait object" (keyword dyn)However, because they are dynamically sized types, you often don't see them in this basic form alone. You'll most often see them used with some form of indirection, be it reference, Box, Arc or "smart pointer" type. So strictly speaking, a &str is a "reference to string slice".
But the "reference to-" prefix is not particularly helpful in most contexts and is very wordy. So most will colloquially refer to &str as a "string slice" unless more precise terminology is warranted. If someone mentions a "slice", you know they're referring to a "dynamically-sized view into a contiguous sequence"; the exact construction of is not important to its meaning.