Stargateur's answer一般来说是个不错的建议,但我们假设您不能重写API来消除isize,或者限制usize的范...
记住,isize可以为负,但usize不能为负。尽管isize和usize现在大小相同是事实,但以后可能就不是机器架...
OTOH if we fix the maximum allowed value size toisize::MAX, then there is a subset of C types (those with a larger size) that we can't interface with via C FFI. This might be a trade-off worth making, e.g., if choosingisize::MAXsimplifies Rust unsafe code, or if theusize::M...
cur_index: Option<usize>, } impl Iterator for DmaBuffIter { type Item = &'static [u16; 4]; fn next(&mut self) -> Option<Self::Item> { match &mut self.cur_index { Some(i) => { *i += 1; } None => { self.cur_index = Some(0); } }; DMA_BUFF.get_buff(self.cur_ind...
Rust -isize和usize的可用性因为isize是指针大小的有符号整数类型,而usize是指针大小的无符号整数类型。