You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This becomes annoying when you change the values on the right hand side, because you have to update the length on the left to match. In this case, it's often not necessary to be explicit about the type because it can be fully inferred. But there are cases where it's less convenient, such as with trait objects, where the inference can be too narrow without an annotation:
This is an error unless you give a hint to the compiler that the array is of the trait object and not the impl. You can do it like this:
let values = [&MyStructas&MyTrait,&MyStruct];
Which works, but the following would be much clearer:
let values:[&MyTrait; _] = [&MyStruct,&MyStruct];
The text was updated successfully, but these errors were encountered:
peterjoel
changed the title
Placeholder syntax should be supported for length parameter in array types, where length can be inferred
Support placeholder syntax for length parameter in array types, when length can be inferred
Apr 16, 2018
Consider code like this:
This becomes annoying when you change the values on the right hand side, because you have to update the length on the left to match. In this case, it's often not necessary to be explicit about the type because it can be fully inferred. But there are cases where it's less convenient, such as with trait objects, where the inference can be too narrow without an annotation:
This is an error unless you give a hint to the compiler that the array is of the trait object and not the impl. You can do it like this:
Which works, but the following would be much clearer:
The text was updated successfully, but these errors were encountered: