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