【Rust日报】 2019-08-21
「官方」async_await将在Rust 1.39稳定版中发布
目前,相关的PR已被合并。
Read More: https://github.com/rust-lang/rust/pull/63209#issuecomment-523113079
宣告:async-std 异步标准库的测试版
#async_std
并打算在2019年9月26日前发布1.0版。该库附带了一本书和完善的应用编程接口文档,并将很快提供一个稳定的接口来支持异步库和应用程序。
虽然我们在1.0版本之前没有承诺过应用编程接口的稳定性,但是我们也不期望做出任何突破性的改变。
该库由Rust异步生态系统工作组成员 stjepang 开发,他也是crossbeam的主要开发者,同时也供职于Rust咨询公司Ferrous Systems。
- Read More: https://async.rs/blog/announcing-async-std/
- Book: https://book.async.rs/
- Docs: https://docs.rs/async-std/0.99.3/async_std/
性能测评: C vs Rust vs Go
基于问题:对于给定的图像,在图像中找到流行的颜色,这样用户就可以根据它的颜色来浏览图像。
使用算法:histogram
最终测试结果:
C 14s
Rust 21s
Go 34s
结论:在实现高效算法方面,Rust似乎处于最佳状态。它不会在抽象之中隐藏任何东西,你仍然可以像Go一样高效开发。
- Read More: https://medium.com/@marek.michalik/c-vs-rust-vs-go-performance-analysis-945ab749056c
- histogram算法: https://spin.atomicobject.com/2016/12/07/pixels-and-palettes-extracting-color-palettes-from-images/
CPU原子和顺序解释
本文简要地解释了CPU内存顺序是如何工作的,以及它们是做什么的,这对于理解Rust中的原子类型和Mutex锁比较重要。
Read More: https://fy.blackhats.net.au/blog/html/2019/07/16/cpu_atomics_and_orderings_explained.html
介绍Glam和Mathbench
glam是一个用于游戏和图形的简单快速Rust线性代数库。mathbench是一组单元测试和基准测试。性能相比于cgmath和nalgebra,有一定的优势。并且有SIMD支持。
- Read More: http://bitshifter.github.io/2019/07/10/introducing-glam-and-mathbench/
- Glam: https://docs.rs/crate/glam/0.7.1
- Mathbench-rs: https://github.com/bitshifter/mathbench-rs
「官方」Rust编译器团队活动页
该网站记录了Rust官方编译器团队的一些活动记录、文档、会议等信息,感兴趣的可以关注。
Read More: https://rust-lang.github.io/compiler-team/
<_>::v::<_>: 一件有趣的Rust「艺术品」
<_>::v::<_> 像个猫头鹰(面试题 +1)
原始代码:
type O = u8;
trait V {
fn v<T: Default>() -> (T, Self);
}
impl V for O {
fn v<T: Default>() -> (T, Self) {
(T::default(), 0)
}
}
fn main() {
let owl = <_>::v::<_>;
println!("{:?}", owl() as (O, O));
}
网友改进:
type O = u8;
const O: O = 0;
trait V {
fn v<T: Default>() -> (T, Self);
}
impl V for O {
fn v<T: Default>() -> (T, Self) {
(T::default(), O)
}
}
#[test]
fn test() {
let owl = <_>::v::<_>;
assert_eq!(owl(), (O, O));
}
你看懂了吗?
HinT:
<_>::v::<_>其实等价于<u8>::v::<u8>,类型推导o和0不要傻傻分不清楚
Read More: https://chrismorgan.info/blog/rust-artwork-owl/
gym-rs: OpenAI gym的Rust绑定
测试覆盖率报告作为代码阅读工具
本文教你一种使用覆盖率报告阅读项目源码的方法,以alacritty的代码为示例,使用kcov来说明。
- Read More: https://www.joshmcguigan.com/blog/coverage-reports-code-reading-tool/
- alacritty: https://github.com/jwilm/alacritty
awmp:用于在actix-web中处理文件上传
是对actix-multipart的包装,方便使用
Repo: https://crates.io/crates/awmp
construct: 一个用同伦映射构造三维几何的高阶函数编程库
什么是同伦(Homotopy)映射?
同伦是两个函数之间的连续变形。考虑将两个函数f和g与一个在0和1之间的参数结合起来,这样把参数设为0就得到f,把参数设为1就得到g。换句话说,它让你可以在函数之间平滑地插值。这个库使用了一个简化的同伦版本,用于构建三维几何。
Repo: https://github.com/pistondevelopers/construct
一个Yew使用react组件的示例
Repo: https://github.com/hobofan/yew-react-example
Meuse: 一个免费的Rust私有Cargo注册仓
Repo: https://github.com/mcorbin/meuse
Glitter: 漂亮地输出Git仓库状态信息
用于在shell提示符中显示关于Git仓库的信息
Repo: https://github.com/glfmn/glitter/tree/v0.2.0
「系列文章」Rust中如何优化async/await Part I
官方在稳定Rust异步async/await的过程中,解决了很多问题。其中之一是从异步到状态机的转换,目前不是最优的方法。所以,这导致状态变得比需要的大得多。由于状态大小实际上是超线性增长的,所以当状态大小增长超过正常系统线程的大小时,可能会触发实际栈上的栈溢出。
该文作者过去几个月主要是解决这个问题,他写下这篇文章来告诉大众该问题的优化过程。好事多磨。
- Read More: https://tmandry.gitlab.io/blog/posts/optimizing-await-1/
- 相关issues: https://github.com/rust-lang/rust/issues/52924
- 相关issues: https://github.com/rust-lang/rust/issues/62149
From 日报小组 Chaos
日报订阅地址:
独立日报订阅地址:
社区学习交流平台订阅:
Leave 【Rust日报】 2019-08-21 to:
Read more #rust posts
Best Posts From ChaosBot
We have not curated any of blackanger's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From ChaosBot
- 【Rust日报】 2019-09-06
- 【Rust日报】 2019-09-05
- 【Rust日报】2019-09-04
- 【Rust日报】 2019-09-03
- 【Rust日报】 2019-09-01
- 【Rust日报】 2019-08-30
- 【Rust日报】 2019-08-29
- 【Rust日报】 2019-08-28
- 【Rust日报】 2019-08-27
- 【Rust日报】2019-08-26
- 【Rust日报】 2019-08-25
- 【Rust日报】 2019-08-24
- 【Rust日报】 2019-08-23
- 【Rust日报】 2019-08-22
- 【Rust日报】 2019-08-21
- 【Rust日报】2019-08-20
- 【Rust日报】2019-08-19
- 【Rust日报】2019-08-18
- 【Rust日报】 2019-08-17
- 【Rust日报】 2019-08-16