bevy_reflect

Trait Tuple

Source
pub trait Tuple: Reflect {
    // Required methods
    fn field(&self, index: usize) -> Option<&dyn Reflect>;
    fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>;
    fn field_len(&self) -> usize;
    fn iter_fields(&self) -> TupleFieldIter<'_> ;
    fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>;
    fn clone_dynamic(&self) -> DynamicTuple;
}
Expand description

A trait used to power tuple-like operations via reflection.

This trait uses the Reflect trait to allow implementors to have their fields be dynamically addressed by index.

This trait is automatically implemented for arbitrary tuples of up to 12 elements, provided that each element implements Reflect.

§Example

use bevy_reflect::{Reflect, Tuple};

let foo = (123_u32, true);
assert_eq!(foo.field_len(), 2);

let field: &dyn Reflect = foo.field(0).unwrap();
assert_eq!(field.downcast_ref::<u32>(), Some(&123));

Required Methods§

Source

fn field(&self, index: usize) -> Option<&dyn Reflect>

Returns a reference to the value of the field with index index as a &dyn Reflect.

Source

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.

Source

fn field_len(&self) -> usize

Returns the number of fields in the tuple.

Source

fn iter_fields(&self) -> TupleFieldIter<'_>

Returns an iterator over the values of the tuple’s fields.

Source

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Drain the fields of this tuple to get a vector of owned values.

Source

fn clone_dynamic(&self) -> DynamicTuple

Clones the struct into a DynamicTuple.

Trait Implementations§

Source§

impl GetTupleField for dyn Tuple

Source§

fn get_field<T: Reflect>(&self, index: usize) -> Option<&T>

Returns a reference to the value of the field with index index, downcast to T.
Source§

fn get_field_mut<T: Reflect>(&mut self, index: usize) -> Option<&mut T>

Returns a mutable reference to the value of the field with index index, downcast to T.

Implementations on Foreign Types§

Source§

impl Tuple for ()

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration> Tuple for (A,)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G, H)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G, H, I)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G, H, I, J)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G, H, I, J, K)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Source§

impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration, L: Reflect + TypePath + GetTypeRegistration> Tuple for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

fn field(&self, index: usize) -> Option<&dyn Reflect>

Source§

fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleFieldIter<'_>

Source§

fn drain(self: Box<Self>) -> Vec<Box<dyn Reflect>>

Source§

fn clone_dynamic(&self) -> DynamicTuple

Implementors§