Search code examples
rustrust-obsolete

Difference between &T and T/&, ~T and T/~


What is the difference between having the pointer type prefixing the type versus having it postfix with a slash prior to it. What does the slash even mean?


Solution

  • The syntax T/~ and T/& is basically deprecated (I'm not even sure if the compiler still accepts it). In the initial phases of the transition to the new vector scheme, [T]/~ indicated a unique pointer to a vector and [T]/& indicated a slice. These types are now written ~[T] and &[T] respectively. The slash is still used for fixed-length vectors, e.g., [int]/3. This is exactly equivalent to the C type int[3].