本文簡要介紹rust語言中 Struct std::num::NonZeroU16
的用法。
用法
#[repr(transparent)]pub struct NonZeroU16(_);
一個已知不等於零的整數。
這可以實現一些內存布局優化。例如,Option<NonZeroU16>
與 u16
的大小相同:
use std::mem::size_of;
assert_eq!(size_of::<Option<core::num::NonZeroU16>>(), size_of::<u16>());
相關用法
- Rust NonZeroU16.saturating_pow用法及代碼示例
- Rust NonZeroU16.checked_pow用法及代碼示例
- Rust NonZeroU16.trailing_zeros用法及代碼示例
- Rust NonZeroU16.checked_mul用法及代碼示例
- Rust NonZeroU16.unchecked_add用法及代碼示例
- Rust NonZeroU16.unchecked_mul用法及代碼示例
- Rust NonZeroU16.checked_add用法及代碼示例
- Rust NonZeroU16.saturating_mul用法及代碼示例
- Rust NonZeroU16.leading_zeros用法及代碼示例
- Rust NonZeroU16.is_power_of_two用法及代碼示例
- Rust NonZeroU16.saturating_add用法及代碼示例
- Rust NonZeroU16.checked_next_power_of_two用法及代碼示例
- Rust NonZeroU128.checked_pow用法及代碼示例
- Rust NonZeroU128.leading_zeros用法及代碼示例
- Rust NonZeroU128.saturating_pow用法及代碼示例
- Rust NonZeroU128.saturating_add用法及代碼示例
- Rust NonZeroU128.is_power_of_two用法及代碼示例
- Rust NonZeroU128.unchecked_add用法及代碼示例
- Rust NonZeroU128.saturating_mul用法及代碼示例
- Rust NonZeroU128用法及代碼示例
- Rust NonZeroU128.checked_mul用法及代碼示例
- Rust NonZeroU128.trailing_zeros用法及代碼示例
- Rust NonZeroU128.unchecked_mul用法及代碼示例
- Rust NonZeroU128.checked_add用法及代碼示例
- Rust NonZeroU128.checked_next_power_of_two用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 Struct std::num::NonZeroU16。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。