Updated docs for `List Trait in bevy_reflect` (#6872)

# Objective

Fixes #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>
This commit is contained in:
Zhell 2022-12-07 23:10:25 +00:00
parent 10898d1dc9
commit e08701307b

View file

@ -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`].