yeet World::components_mut >:( (#4092)
# Objective
make bevy ecs a lil bit less unsound
## Solution
yeet unsound API `World::components_mut`:
```rust
use bevy_ecs::prelude::*;
#[derive(Component)]
struct Foo(u8);
#[derive(Debug, Component)]
struct Bar([u8; 100]);
fn main() {
let mut world = World::new();
let e = world.spawn().insert(Foo(0)).id();
*world.components_mut() = Default::default();
let bar = world.entity_mut(e).remove::<Bar>().unwrap();
// oopsies reading memory copied from outside allocation
dbg!(bar);
}
```
This commit is contained in:
parent
54fbaf4b4c
commit
050d2b7f00
@ -152,12 +152,6 @@ impl World {
|
||||
&self.components
|
||||
}
|
||||
|
||||
/// Retrieves a mutable reference to this world's [Components] collection
|
||||
#[inline]
|
||||
pub fn components_mut(&mut self) -> &mut Components {
|
||||
&mut self.components
|
||||
}
|
||||
|
||||
/// Retrieves this world's [Storages] collection
|
||||
#[inline]
|
||||
pub fn storages(&self) -> &Storages {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user