Question about angle brackets in paths

Hey folks,

I'm wondering why I need in some cases angle brackets for paths and in others not. See here. When I remove the angle brackets in line 6 at the slice I get an error but with no explaination.

Can anybody explain this?


Array of T implements Clone if T implements clone:

impl<T, const N: usize> Clone for [T; N]
    T: Clone

There must be a similar implementation for slice, but I can't find it right now (I'm on the phone).

1 Like

You have to use a qualified path for things that aren't identifiers or a handful of keywords.

Sidenote, [T] is not Sized and thus cannot implement Clone. So test2 is not callable.


It's to avoid syntactic ambiguity. In expression position, [ would begin an array literal, so you need some sort of disambiguation to get a type. This is exactly the same reason as that of the turbofish.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.