Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/bevy_reflect/src/impls/smallvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ where
});
SmallVec::push(self, value);
}

fn pop(&mut self) -> Option<Box<dyn Reflect>> {
self.pop().map(|value| Box::new(value) as Box<dyn Reflect>)
}
}

impl<T: smallvec::Array + Send + Sync + 'static> Reflect for SmallVec<T>
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_reflect/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ impl<T: FromReflect> List for Vec<T> {
});
Vec::push(self, value);
}

fn pop(&mut self) -> Option<Box<dyn Reflect>> {
self.pop().map(|value| Box::new(value) as Box<dyn Reflect>)
}
}

impl<T: FromReflect> Reflect for Vec<T> {
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_reflect/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub trait List: Reflect + Array {
/// Appends an element to the list.
fn push(&mut self, value: Box<dyn Reflect>);

/// Removes the last element from the list (highest index in the array) and returns it, or [`None`] if it is empty.
fn pop(&mut self) -> Option<Box<dyn Reflect>>;

/// Clones the list, producing a [`DynamicList`].
fn clone_dynamic(&self) -> DynamicList {
DynamicList {
Expand Down Expand Up @@ -151,6 +154,10 @@ impl List for DynamicList {
DynamicList::push_box(self, value);
}

fn pop(&mut self) -> Option<Box<dyn Reflect>> {
self.values.pop()
}

fn clone_dynamic(&self) -> DynamicList {
DynamicList {
name: self.name.clone(),
Expand Down