本文简要介绍rust语言中 std::ffi::NulError.nul_position
的用法。
用法
pub fn nul_position(&self) -> usize
返回导致 CString::new
失败的切片中 nul 字节的位置。
例子
use std::ffi::CString;
let nul_error = CString::new("foo\0bar").unwrap_err();
assert_eq!(nul_error.nul_position(), 3);
let nul_error = CString::new("foo bar\0").unwrap_err();
assert_eq!(nul_error.nul_position(), 7);
相关用法
- Rust NulError.into_vec用法及代码示例
- Rust NulError用法及代码示例
- Rust NonZeroU128.checked_pow用法及代码示例
- Rust NonZeroUsize.checked_next_power_of_two用法及代码示例
- Rust NonZeroI128.saturating_pow用法及代码示例
- Rust NonZeroI64.wrapping_abs用法及代码示例
- Rust NonZeroU64.checked_mul用法及代码示例
- Rust NonZeroU16.saturating_pow用法及代码示例
- Rust NonZeroU8.checked_add用法及代码示例
- Rust NonZeroUsize.checked_pow用法及代码示例
- Rust NonZeroU8.unchecked_add用法及代码示例
- Rust NonZeroUsize.leading_zeros用法及代码示例
- Rust NonZeroI32.trailing_zeros用法及代码示例
- Rust NonZeroI8.saturating_pow用法及代码示例
- Rust NonZeroIsize.wrapping_abs用法及代码示例
- Rust NonZeroU128.leading_zeros用法及代码示例
- Rust NonZeroU16.checked_pow用法及代码示例
- Rust NonZeroI16.saturating_abs用法及代码示例
- Rust NonZeroI16.leading_zeros用法及代码示例
- Rust NonZeroU32.checked_mul用法及代码示例
- Rust NonZeroI8.unchecked_mul用法及代码示例
- Rust NonZeroU16.trailing_zeros用法及代码示例
- Rust Not.not用法及代码示例
- Rust NonZeroIsize.checked_mul用法及代码示例
- Rust NonZeroI64.saturating_pow用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 std::ffi::NulError.nul_position。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。