[rust up] Linux Kernel加入了第一个Rust写的有用模块
这个模块是 Asix PHY 的网络驱动程序。它是作为用 C 编写的现有驱动程序的替代方法提供的。这些功能是等效的。
看看 commit 信息:
net: phy: add Rust Asix PHY driver
This is the Rust implementation of drivers/net/phy/ax88796b.c. The
features are equivalent. You can choose C or Rust version kernel
configuration.
链接: https://fosstodon.org/@kernellogger/111741507899977461
GitHub: https://github.com/torvalds/linux/blob/master/drivers/net/phy/ax88796b_rust.rs
[new lib] rs-measures
一个 Rust 宏库,用于将数字静态封装在具有度量单位的对象中。
动机:使用原始的 Rust 数据类型来存储物理或几何量的值,可能会出现一些编程错误。但是,通过将这些值封装在自定义类型中,可以避免其中的一些值,而无需运行时成本。
使用示例:
mod units;
use units::*;
fn main() {
// 距离
let distance = Measure::<KiloMetre>::new(100.);
println!("The distance is {di