- Added `.zed/settings.json` to configure rust-analyzer with `leptosfmt`. - Created `rustfmt.toml` with max width 120 and comment wrapping settings. - Applied consistent formatting across all modified crates using rustfmt. - Reorganized import statements and improved code style in multiple modules.
39 lines
920 B
Rust
39 lines
920 B
Rust
use bevy_ecs::component::Component;
|
|
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
|
use vanth::Vanth;
|
|
|
|
// TODO: derive `Vanth`
|
|
#[derive(Debug, Deserialize, Component, Serialize)]
|
|
struct Foo {}
|
|
|
|
#[test]
|
|
fn test_derive() {
|
|
#[derive(Deserialize, Serialize, Vanth)]
|
|
struct Foo<T: Vanth> {
|
|
field_a: i32,
|
|
field_b: String,
|
|
inner: T,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Vanth)]
|
|
struct Bar {
|
|
field_a: i32,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Vanth)]
|
|
struct Qux<T: Vanth, S: Vanth> {
|
|
field_a: i32,
|
|
field_b: String,
|
|
inner: T,
|
|
inner_2: S,
|
|
}
|
|
|
|
let base = "integration::derive::";
|
|
|
|
assert_eq!(Bar::ty(), format!("{base}Bar"));
|
|
assert_eq!(Foo::<Bar>::ty(), format!("{base}Foo<{base}Bar>"));
|
|
assert_eq!(
|
|
Qux::<Bar, Foo<Bar>>::ty(),
|
|
format!("{base}Qux<{base}Bar,{base}Foo<{base}Bar>>")
|
|
);
|
|
}
|