Description
Consider the following struct that simply wraps an array pointer:
struct Latin1String {
data: ~[u8]
}
Due to the move semantic one cannot use Latin1String directly as argument type. However, using &Latin1String for arguments currently implies double-indirection when accessing characters even if semantically there would be no difference if internally &Latin1String is implemented as a copy via registers all fields of Latin1String.
It would be nice if Rust implement such optimization for &T arguments effectively turning that into "the most efficient way to pass read-only parameters to a function" .
Similar problem exists when a generic function takes &T argument and is instantiated with int and similar built-in types.
Note that C++ has the same problem when (const T&) leads to inefficient passing of 1-3 word-sized T like int or double forcing to use workarounds like inlined functions in headers, explicit template specialization for primitive types etc.