Takes the first two commits from #15375 and adds suggestions from this comment: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366968300 See #15375 for more reasoning/motivation. ## Rebasing (rerunning) ```rust git switch simpler-lint-fixes git reset --hard main cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate cargo fmt --all git add --update git commit --message "rustfmt" cargo clippy --workspace --all-targets --all-features --fix cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate cargo fmt --all git add --update git commit --message "clippy" git cherry-pick e6c0b94f6795222310fb812fa5c4512661fc7887 ```
36 lines
953 B
Rust
36 lines
953 B
Rust
use crate::{
|
|
self as bevy_reflect, std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize,
|
|
};
|
|
use bevy_reflect_derive::impl_reflect_opaque;
|
|
|
|
impl_reflect_opaque!(::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);
|
|
}
|
|
}
|