Rust宣布成立错误处理项目组

Rust 官方宣布成立错误处理组, 隶属于 libs team.该组的主要目标为:

  1. 定义和编纂常见的错误处理术语.
  2. 就当前错误处理最佳实践达成共识.
  3. 识别 Rust 错误处理中存在的痛点.
  4. 交流当前错误处理最佳实践.
  5. 巩固Rust错误处理生态系统.

https://blog.rust-lang.org/inside-rust/2020/09/18/error-handling-wg-announcement.html

Bevy 0.2 版本发布

Bevy 0.2 正式发布了. 值得注意的特性包括:

  1. Async Task System.在此之前, Bevy 使用 Rayon 来运行各种多线程的任务. Rayon 的优点是使用简单,缺点是很容易造成 cpu-hungry. 为了解决这些不足, Bevy 自己构建了一个对异步任务友好的 task system, cpu 的使用率获得巨大的提升.
  2. Web 平台的初始支持.目前已经有一个 Bevy的子集,通过 WASM 来让 Bevy 的 apps 可以在 web 上运行. 当然目前来说支持的功能非常有限.
  3. 并发Queries.Bevy ECS Quries 是从 Entity Componet System 中提取数据的一个非常方便的方式. 0.2版本可以非常便利的并发来进行 queries 的遍历.
  4. 重写 Transform Sytem.
  5. Joystick/Gamepad 输入支持.
  6. 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


©著作权归作者所有:来自51CTO博客作者mob604756f79c64的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. 【Rust日报】2020-09-19 Rust 2021: 降低门槛
  2. 信创稳妥落地,一云多芯协同是唯一答案!
  3. 什么是MongoDB?Python爬虫为什么使用MongoDB?
  4. 程序员必须知道的9大数据挖掘工具
  5. Bootstrap5中文手册完整翻译版发布
  6. 4月30日做作业卷子
  7. 视频:使用Docker搭建RabbitMQ环境
  8. 关于驰骋BPM对银行行业的问题答复
  9. 微信支付V3实现Payment Spring Boot 1.0.4.RELEASE发布,支持商家

随机推荐

  1. android添加桌面快捷方式
  2. Android NDK How-To ---- Android 4.4
  3. Android的通信机制与网络(一)
  4. port exosip to android
  5. android新闻应用、应用锁、小说阅读、短
  6. Android & Vibrator
  7. Android NetworkInfo.DetailedState 获取
  8. Android内核开发:图解Android系统的启动过
  9. android 升级 4.1后出现java.lang.NoSuch
  10. Android Studio 导出未签名 apk