Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/impls/alloc/vec.rs
6600 views
1
use bevy_reflect_derive::impl_type_path;
2
3
use crate::impls::macros::impl_reflect_for_veclike;
4
#[cfg(feature = "functions")]
5
use crate::{
6
from_reflect::FromReflect, type_info::MaybeTyped, type_path::TypePath,
7
type_registry::GetTypeRegistration,
8
};
9
10
impl_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
);
18
impl_type_path!(::alloc::vec::Vec<T>);
19
#[cfg(feature = "functions")]
20
crate::func::macros::impl_function_traits!(::alloc::vec::Vec<T>; <T: FromReflect + MaybeTyped + TypePath + GetTypeRegistration>);
21
22
#[cfg(test)]
23
mod 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
}
36
37