< 返回版块

长琴 发表于 2024-01-14 11:40

Tags:rust,日报,rs-measures,astratomic,argmin,backhand

[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 {distance}.");
    let distance_value: f64 = distance.value;
    println!("The distance is {distance_value}.");
    
    // 温度
    let point1 = MeasurePoint::<Celsius>::new(10.);
    let variation = Measure::<Celsius>::new(2.);
    let point2 = point1 + variation;
    println!("When increasing temperature {point1} by {variation}, we reach temperature {point2}.");
    
    // 3D
    let position1 = MeasurePoint3d::<Metre>::new(4., 7., -3.);
    let displacement = Measure3d::<Metre>::new(2., -12., -2.);
    let position2 = position1 + displacement;
    println!("After I moved from position {position1} in the space");
    println!("by {displacement}, my position was {position2}.");
}

以上代码分别输出:

# 距离
The distance is 100 km.
The distance is 100.

# 温度
When increasing temperature at 10 °C by 2 °C, we reach temperature at 12 °C.

# 3D
After I moved from position at (4, 7, -3) m in the space
by (2, -12, -2) m, my position was at (6, -5, -5) m.

Docs: https://github.com/carlomilanesi/rs-measures/tree/main/docs

GitHub: https://github.com/carlomilanesi/rs-measures/

[new ver] astratomic v0.2.0发布

Astratomic是一款生存游戏,从Noita和Starbound等游戏中汲取灵感。由与 Noita 类似的引擎提供动力,使用 Rust 从头开始制作。

  • 新原子!水、熔岩、砾石、泥土和草。
  • 分块装卸系统,随心所欲地行走或挖矿。
  • 热加载原子材料特性!
  • 用于处理推/拉原子的粒子系统。
  • 更好的玩家工具行为。
  • 存储游戏状态的文件。
  • 流畅的玩家相机。

GitHub: https://github.com/spicylobstergames/astratomic

[new ver] argmin v0.9.0发布

时隔一年,argmin 终于发布 0.9.0 版本了,主要更新如下:

  • 线搜索现在可以正确地搜索梯度而不是参数向量。
  • SteepestDescent 现在可以正确跟踪prev_param。
  • ArgminInv 现在也实现了 1D 矩阵。
  • 添加了另一个如何使用 Nelder-Mead 的示例。
  • 修复了文档中的一些错别字和错误。

argmin 是一个 Rust 库,它提供了一系列数值优化方法和用于开发优化算法的框架。

上面的更新看起来好像有点抽象,是因为这个项目其实是一个算法优化方法的框架(可以阅读下面的 book)。argmin 的意思应该也是最小化目标的意思,它常用在机器学习中(最小化目标函数)。

Book: https://argmin-rs.org/book/

Website: https://argmin-rs.org/

GitHub: https://github.com/argmin-rs/argmin

[new ver] backhand v0.14.0发布

backhand 用来读取、创建、修改SquashFS文件系统。

Squashfs(.sfs)是一套供 Linux 核心使用的 GPL 开源只读压缩文件系统。Squashfs 能够为文件系统内的文件、 inode 及 目录结构进行压缩,并支持最大 1024 千字节的块大小,以提供更大的压缩比。

Squashfs 的设计是专门为一般的只读文件系统的使用而设计,它可应用于数据备份,或是系统资源紧张的电脑上使用。最初版本的 Squashfs 采用 gzip 的数据压缩。版本 2.6.34 之后的 Linux 内核增加了对 LZMA[1] 和 LZO [2] 压缩算法的支持,版本 2.6.38 的内核增加了对 LZMA2 的支持,该算法同时也是 xz 使用的压缩算法。[3]

——来自维基百科:https://zh.wikipedia.org/wiki/SquashFS

更新日志:https://github.com/wcampbell0x2a/backhand/releases/tag/v0.14.0

GitHub: https://github.com/wcampbell0x2a/backhand


From 日报小组 长琴

社区学习交流平台订阅:

评论区

写评论
Bai-Jinlin 2024-01-14 13:37

顶天是,《这个模块尝试进行了rust化基础改造,将入口文件加入了rust版的实现》,不知道的看标题还以为整个模块都是rust写的呢

1 共 1 条评论, 1 页