pu369com

2021年8月25日

Rust从&[u8] bytes中读取任意类型的整数(如i32, u32等多种类型)

摘要: 其实代码最后一行实现了同样功能,但可以用来学习trait和macro use std::convert::TryInto; pub trait ReadInteger<T> { fn from_le_bytes(data: &[u8]) -> T; fn from_be_bytes(data: &[ 阅读全文

posted @ 2021-08-25 16:04 pu369com 阅读(611) 评论(0) 推荐(0) 编辑

导航