Rust 视界
2.37K subscribers
461 photos
2 videos
17 files
5.09K links
Rust 热点、开源项目、动态
Download Telegram
mask,一个通过 markdown 配置的任务运行工具

#rust #cli

编写 markdown 文件,通过 mask 运行文档中的任务,目前支持 node、bash、python、php、ruby。例如:你可以配置一个 server 任务和一个 snapshot 任务,让 python 运行 web 服务,让 node 运行 puppeteer 为每一个页面生成一张 png 图片。

[Read More](https://github.com/jakedeichert/mask)
WebAssembly 实现的路径查找 Demo

#wasm

开发者是上面 mask 的作者,他通过编写 rust 编译成 wasm,使用浏览器 canvas2D API 实现了一个寻找路径的 Demo,可以[在线体验](https://jakedeichert.github.io/wasm-astar/)。

[Read More](https://github.com/jakedeichert/wasm-astar)
正在想要不要使用 unsafe 吗?可以考虑下 zerocopy

#unsafe

[zerocopy](https://crates.io/crates/zerocopy) 可以为具有的某些属性的类型提供标记 trait。例如,将任意字节序列(正确长度)解释为类型的实例是安全的。 它还提供了多个 derive,自动分析的类型并确定它是否符合标准。它提供了零成本抽象,允许开发者在原始和类型字节表示之间进行转换,解锁“零拷贝”解析和序列化。 到目前为止,它已被用于网络数据包解析和序列化,图像处理,操作系统程序等。

它最初是为网络堆栈开发的,作者[去年就此进行了讨论](https://www.youtube.com/watch?v=UfMOOxOGCmA),因此,他们的项目具有零拷贝解析和所有数据包的序列化功能,而整个25K行代码仓库只有一个 unsafe 关键字。

[Read More](https://www.reddit.com/r/rust/comments/cfh8la/thinking_of_using_unsafe_try_this_instead/)
From 日报小组 格朗
treelike - 一个用于方便地实现树结构的辅助包

它提供了一个 Treelike trait,实现其中的两个方法 content()children() 即可。

作者是在在多个项目中重复写树实现得出的灵感。赞一个!

[Repo](https://github.com/djugei/treelike)
Neuralink 在组建一个队伍,寻找有 Rust 经验的工程师

> Neuralink is developing ultra-high bandwidth brain-machine interfaces to
connect humans and computers. We are building a team of
multidisciplinary experts passionate about making a world-changing
impact.

[Read More](https://jobs.lever.co/neuralink/efb72bf6-5a55-434e-a0fd-9197f8485b55)
siderophile - 暴露你的包中的不安全代码

可以看作一个代码审查辅助工具。不能完全保证找出所有不安全代码,但可以成为一个有效的生产力工具。会根据不安全代码的使用进行评分,给出一个报告:

Badness Function

012 molasses::crypto::hash::HashFunction::hash_serializable

005 molasses::crypto::hash::HashContext::feed_serializable

003 molasses::utils::derive_node_values

003 molasses::application::encrypt_application_message

003 molasses::application::decrypt_application_message

003 molasses::group_ctx::GroupContext::new_from_parts

003 molasses::group_ctx::GroupContext::from_welcome

003 molasses::group_ctx::GroupContext::update_transcript_hash

003 molasses::group_ctx::GroupContext::update_tree_hash

003 molasses::group_ctx::GroupContext::update_epoch_secrets

003 molasses::group_ctx::GroupContext::apply_update

...


[Read More](https://blog.trailofbits.com/2019/07/01/siderophile-expose-your-crates-unsafety/)
[Repo](https://github.com/trailofbits/siderophile)
slice-group-by - 对 slice 进行分组的库

非常 Nice。第一眼就爱上了。

use slice_group_by::GroupBy;

let slice = &[1, 1, 1, 3, 3, 2, 2, 2];

let mut iter = slice.linear_group_by(|a, b| a == b);

assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next(), None);

use slice_group_by::StrGroupBy;

let string = "aaaabbbbb饰饰cccc";

let mut iter = string.linear_group_by(|a, b| a == b);

assert_eq!(iter.next(), Some("aaaa"));
assert_eq!(iter.next(), Some("bbbbb"));
assert_eq!(iter.next(), Some("饰饰"));
assert_eq!(iter.next(), Some("cccc"));
assert_eq!(iter.next(), None);


[Repo](https://github.com/Kerollmops/slice-group-by#linear-searched-immutable-groups)
又一篇《理解生命周期》

初学者可以多看看。

[Read More](https://rniczh.github.io/blog/lifetimes-intro/)
rustc 已经被添加进了 Android 工具链

[Link](https://android.googlesource.com/toolchain/rustc/)
From 日报小组 Mike
cargo-bloat 0.8 发布

#cargo

cargo-bloat 是一个可以帮助你缩减crate大小的库。新的版本有意思的是,cargo-bloat用cargo-bloat缩减了自己,结果令人满意:大小缩减了5倍,性能提升了10倍。

[Read More](https://www.reddit.com/r/rust/comments/cg3p5m/cargobloat_08_debloated_5x_smaller_10x_faster/)
chttp 0.5 发布

#async

chttp是一个http客户端,最近全面升级为async/await,并且改进了API。适合学习async/await

[Read More](https://github.com/sagebind/chttp/releases/tag/0.5.0)