mirror of
https://github.com/bevyengine/bevy
synced 2024-12-25 04:23:08 +00:00
547b1c7a7a
# Objective - Fixes #14969 ## Solution - Added `Deserialize` to the list of reflected traits for `SmolStr` ## Testing - CI passed locally. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
34 lines
957 B
Rust
34 lines
957 B
Rust
use crate::{self as bevy_reflect};
|
|
use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize};
|
|
use bevy_reflect_derive::impl_reflect_value;
|
|
|
|
impl_reflect_value!(::smol_str::SmolStr(
|
|
Debug,
|
|
Hash,
|
|
PartialEq,
|
|
Default,
|
|
Serialize,
|
|
Deserialize,
|
|
));
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use crate::{FromReflect, PartialReflect};
|
|
use smol_str::SmolStr;
|
|
|
|
#[test]
|
|
fn should_partial_eq_smolstr() {
|
|
let a: &dyn PartialReflect = &SmolStr::new("A");
|
|
let a2: &dyn PartialReflect = &SmolStr::new("A");
|
|
let b: &dyn PartialReflect = &SmolStr::new("B");
|
|
assert_eq!(Some(true), a.reflect_partial_eq(a2));
|
|
assert_eq!(Some(false), a.reflect_partial_eq(b));
|
|
}
|
|
|
|
#[test]
|
|
fn smolstr_should_from_reflect() {
|
|
let smolstr = SmolStr::new("hello_world.rs");
|
|
let output = <SmolStr as FromReflect>::from_reflect(&smolstr);
|
|
assert_eq!(Some(smolstr), output);
|
|
}
|
|
}
|