【Rust日报】2020-09-21 Rust宣布成立错误处理项目组
16lz
2021-05-09
Rust宣布成立错误处理项目组
Rust 官方宣布成立错误处理组, 隶属于 libs team.该组的主要目标为:
- 定义和编纂常见的错误处理术语.
- 就当前错误处理最佳实践达成共识.
- 识别 Rust 错误处理中存在的痛点.
- 交流当前错误处理最佳实践.
- 巩固Rust错误处理生态系统.
https://blog.rust-lang.org/inside-rust/2020/09/18/error-handling-wg-announcement.html
Bevy 0.2 版本发布
Bevy 0.2 正式发布了. 值得注意的特性包括:
Async Task System
.在此之前, Bevy 使用Rayon
来运行各种多线程的任务.Rayon
的优点是使用简单,缺点是很容易造成cpu-hungry
. 为了解决这些不足, Bevy 自己构建了一个对异步任务友好的task system
, cpu 的使用率获得巨大的提升.Web 平台的初始支持
.目前已经有一个Bevy
的子集,通过WASM
来让 Bevy 的 apps 可以在 web 上运行. 当然目前来说支持的功能非常有限.并发Queries
.Bevy ECS Quries 是从Entity Componet System
中提取数据的一个非常方便的方式.0.2
版本可以非常便利的并发来进行 queries 的遍历.重写 Transform Sytem
.Joystick/Gamepad 输入支持
.Bevy ECS 性能提升
.
https://bevyengine.org/news/bevy-0-2/
ouroboros 简单易用的 自我引用struct 生成器
ouroboros 可以让你非常简单地就能创建复杂的自我引用 struct. 简单用法参考下面例子.
use ouroboros::self_referencing;
#[self_referencing]
struct MyStruct {
int_data: Box<i32>,
float_data: Box<f32>,
#[borrows(int_data)]
int_reference: &'this i32,
#[borrows(mut float_data)]
float_reference: &'this mut f32,
}
fn main() {
let mut my_value = MyStructBuilder {
int_data: Box::new(42),
float_data: Box::new(3.14),
int_reference_builder: |int_data: &i32| int_data,
float_reference_builder: |float_data: &mut f32| float_data,
}.build();
// Prints 42
println!("{:?}", my_value.with_int_data_contents(|int_data| *int_data));
// Prints 3.14
println!("{:?}", my_value.with_float_reference(|float_reference| **float_reference));
// Sets the value of float_data to 84.0
my_value.with_mut(|fields| {
**fields.float_reference = (**fields.int_reference as f32) * 2.0;
});
// We can hold on to this reference...
let int_ref = my_value.with_int_reference(|int_ref| *int_ref);
println!("{:?}", *int_ref);
// As long as the struct is still alive.
drop(my_value);
// This will cause an error!
// println!("{:?}", *int_ref);
}
https://github.com/joshua-maros/ouroboros
更多相关文章
- 【Rust日报】2020-09-19 Rust 2021: 降低门槛
- 信创稳妥落地,一云多芯协同是唯一答案!
- 什么是MongoDB?Python爬虫为什么使用MongoDB?
- 程序员必须知道的9大数据挖掘工具
- Bootstrap5中文手册完整翻译版发布
- 4月30日做作业卷子
- 视频:使用Docker搭建RabbitMQ环境
- 关于驰骋BPM对银行行业的问题答复
- 微信支付V3实现Payment Spring Boot 1.0.4.RELEASE发布,支持商家