Skip to content

Commit

Permalink
Updated docs for List Trait in bevy_reflect (bevyengine#6872)
Browse files Browse the repository at this point in the history
# Objective

Fixes bevyengine#6866.

## Solution

Docs now should describe what the _front_, _first_, _back_, and _last_ elements are for an implementor of the `bevy::reflect::list::List` Trait. Further, the docs should describe how `bevy::reflect::list::List::push` and `bevy::reflect::list::List::pop` should act on these elements.


Co-authored-by: Linus Käll <linus.kall.business@gmail.com>
  • Loading branch information
2 people authored and alradish committed Jan 22, 2023
1 parent 4717bd9 commit 0a18c52
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/bevy_reflect/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ use crate::{
///
/// This is a sub-trait of [`Array`] as it implements a [`push`](List::push) function, allowing
/// it's internal size to grow.
///
/// This trait expects index 0 to contain the _front_ element.
/// The _back_ element must refer to the element with the largest index.
/// These two rules above should be upheld by manual implementors.
pub trait List: Reflect + Array {
/// Appends an element to the list.
/// Appends an element to the _back_ of 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.
/// Removes the _back_ element from the list and returns it, or [`None`] if it is empty.
fn pop(&mut self) -> Option<Box<dyn Reflect>>;

/// Clones the list, producing a [`DynamicList`].
Expand Down

0 comments on commit 0a18c52

Please sign in to comment.