How to index vectors with integer types (besides usize), without explicit cast?

前端 未结 2 1063
情书的邮戳
情书的邮戳 2021-01-21 13:53

There are times when indices need to be tightly packed (mesh geometry for example), where its useful to store indices as u32 instead of usize.

2条回答
  •  -上瘾入骨i
    2021-01-21 14:34

    No.

    If it were your own type, you could implement Index, but it isn't and you can't.

    If you're really, pathologically opposed to casting the index, you could write an adaptor type that does the cast, but that's getting a bit silly.

提交回复
热议问题