当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Rust u32.to_le_bytes用法及代码示例


本文简要介绍rust语言中 u32.to_le_bytes 的用法。

用法

pub const fn to_le_bytes(self) -> [u8; 4]

以 little-endian 字节顺序将此整数的内存表示形式返回为字节数组。

例子

let bytes = 0x12345678u32.to_le_bytes();
assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);

相关用法


注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 u32.to_le_bytes。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。