bevy_reflect/impls/alloc/
vec.rs

1use bevy_reflect_derive::impl_type_path;
2
3use crate::impls::macros::impl_reflect_for_veclike;
4#[cfg(feature = "functions")]
5use crate::{
6    from_reflect::FromReflect, type_info::MaybeTyped, type_path::TypePath,
7    type_registry::GetTypeRegistration,
8};
9
10impl_reflect_for_veclike!(
11    ::alloc::vec::Vec<T>,
12    ::alloc::vec::Vec::insert,
13    ::alloc::vec::Vec::remove,
14    ::alloc::vec::Vec::push,
15    ::alloc::vec::Vec::pop,
16    [T]
17);
18impl_type_path!(::alloc::vec::Vec<T>);
19#[cfg(feature = "functions")]
20crate::func::macros::impl_function_traits!(::alloc::vec::Vec<T>; <T: FromReflect + MaybeTyped + TypePath + GetTypeRegistration>);
21
22#[cfg(test)]
23mod tests {
24    use alloc::vec;
25    use bevy_reflect::PartialReflect;
26
27    #[test]
28    fn should_partial_eq_vec() {
29        let a: &dyn PartialReflect = &vec![1, 2, 3];
30        let b: &dyn PartialReflect = &vec![1, 2, 3];
31        let c: &dyn PartialReflect = &vec![3, 2, 1];
32        assert!(a.reflect_partial_eq(b).unwrap_or_default());
33        assert!(!a.reflect_partial_eq(c).unwrap_or_default());
34    }
35}