Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Rust equivalent of `size_t`?

Tags:

rust

In more practical terms: What integer data type should I use for indices in a vector, length of arrays, etc?

There are lots of discussions on this topic for pre-1.0 Rust floating around on the internet and I can't find an authoritative answer on the final decision.

like image 427
Perseids Avatar asked Aug 31 '15 08:08

Perseids


Video Answer


1 Answers

That would be usize and isize (pointer-size types, unsigned and signed). The reference says that the maximal size of an array is the maximum value of isize such that differences of positions can be calculated.

The functions of std::Vec use usize for all indices, though.

like image 105
filmor Avatar answered Sep 22 '22 18:09

filmor