From a3ac452e44872a9e350d718927d18f9da1a8134d Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 26 Jan 2024 10:37:51 -0300 Subject: [PATCH] Run cargo fmt --- macros/src/types/enum.rs | 10 ++++------ ts-rs/src/lib.rs | 2 +- ts-rs/tests/enum_flattening.rs | 1 - ts-rs/tests/enum_struct_rename_all.rs | 7 +++++-- ts-rs/tests/generics.rs | 5 +---- ts-rs/tests/list.rs | 5 +---- ts-rs/tests/optional_field.rs | 2 +- ts-rs/tests/references.rs | 6 ++++-- ts-rs/tests/semver.rs | 5 +---- ts-rs/tests/serde-skip-with-default.rs | 5 +---- ts-rs/tests/slices.rs | 2 +- ts-rs/tests/struct_rename.rs | 5 ++++- 12 files changed, 24 insertions(+), 31 deletions(-) diff --git a/macros/src/types/enum.rs b/macros/src/types/enum.rs index 0cfcfd9b2..5c0e05669 100644 --- a/macros/src/types/enum.rs +++ b/macros/src/types/enum.rs @@ -50,11 +50,9 @@ pub(crate) fn r#enum_def(s: &ItemEnum) -> syn::Result { Ok(DerivedTS { inline: quote!([#(#formatted_variants),*].join(" | ")), decl: quote!(format!("type {}{} = {};", #name, #generic_args, Self::inline())), - inline_flattened: Some( - quote!( - format!("({})", [#(#formatted_variants),*].join(" | ")) - ) - ), + inline_flattened: Some(quote!( + format!("({})", [#(#formatted_variants),*].join(" | ")) + )), dependencies, name, export: enum_attr.export, @@ -136,7 +134,7 @@ fn format_variant( #name, // At this point inline_flattened looks like // { /* ...data */ } - // + // // To be flattened, an internally tagged enum must not be // surrounded by braces, otherwise each variant will look like // { "tag": "name", { /* ...data */ } } diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index 0df2bc5ba..a7d4a8912 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -107,7 +107,7 @@ //! - `heapless-impl` //! //! Implement `TS` for `Vec` from heapless -//! +//! //! - `semver-impl` //! Implement `TS` for `Version` from semver //! diff --git a/ts-rs/tests/enum_flattening.rs b/ts-rs/tests/enum_flattening.rs index c26ef059a..5d4f9f5db 100644 --- a/ts-rs/tests/enum_flattening.rs +++ b/ts-rs/tests/enum_flattening.rs @@ -105,4 +105,3 @@ fn untagged() { r#"{ a: number, a2: string, } | { b: boolean, } | { c: string, }"# ) } - diff --git a/ts-rs/tests/enum_struct_rename_all.rs b/ts-rs/tests/enum_struct_rename_all.rs index b901a16dc..d681d33cf 100644 --- a/ts-rs/tests/enum_struct_rename_all.rs +++ b/ts-rs/tests/enum_struct_rename_all.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use ts_rs::TS; #[derive(Serialize, Deserialize, TS, Clone)] @@ -21,5 +21,8 @@ pub enum TaskStatus { #[test] pub fn enum_struct_rename_all() { - assert_eq!(TaskStatus::inline(), r#"{ "running": { startedTime: string, } } | { "terminated": { status: number, stdout: string, stderr: string, } }"#) + assert_eq!( + TaskStatus::inline(), + r#"{ "running": { startedTime: string, } } | { "terminated": { status: number, stdout: string, stderr: string, } }"# + ) } diff --git a/ts-rs/tests/generics.rs b/ts-rs/tests/generics.rs index cd8cd6875..b4f8183cd 100644 --- a/ts-rs/tests/generics.rs +++ b/ts-rs/tests/generics.rs @@ -183,10 +183,7 @@ fn default() { struct B>> { u: U, } - assert_eq!( - B::<()>::decl(), - "type B | null> = { u: U, }" - ); + assert_eq!(B::<()>::decl(), "type B | null> = { u: U, }"); assert!(B::<()>::dependencies().iter().any(|dep| dep.ts_name == "A")); #[derive(TS)] diff --git a/ts-rs/tests/list.rs b/ts-rs/tests/list.rs index dfa31261b..92f6f2efe 100644 --- a/ts-rs/tests/list.rs +++ b/ts-rs/tests/list.rs @@ -8,8 +8,5 @@ fn list() { data: Option>, } - assert_eq!( - List::decl(), - "type List = { data: Array | null, }" - ); + assert_eq!(List::decl(), "type List = { data: Array | null, }"); } diff --git a/ts-rs/tests/optional_field.rs b/ts-rs/tests/optional_field.rs index 4912584e5..b7c1f2056 100644 --- a/ts-rs/tests/optional_field.rs +++ b/ts-rs/tests/optional_field.rs @@ -7,7 +7,7 @@ use ts_rs::TS; struct Optional { #[ts(optional)] a: Option, - b: Option + b: Option, } #[test] diff --git a/ts-rs/tests/references.rs b/ts-rs/tests/references.rs index 1aee02b57..e9b2dbbd1 100644 --- a/ts-rs/tests/references.rs +++ b/ts-rs/tests/references.rs @@ -10,6 +10,8 @@ fn references() { num_ref: &'a i32, } - assert_eq!(FullOfRefs::inline(), "{ str_slice: string, ref_slice: Array, num_ref: number, }") + assert_eq!( + FullOfRefs::inline(), + "{ str_slice: string, ref_slice: Array, num_ref: number, }" + ) } - diff --git a/ts-rs/tests/semver.rs b/ts-rs/tests/semver.rs index 5e6ebb8b0..81d307c44 100644 --- a/ts-rs/tests/semver.rs +++ b/ts-rs/tests/semver.rs @@ -11,8 +11,5 @@ fn semver() { version: Version, } - assert_eq!( - Semver::decl(), - "type Semver = { version: string, }" - ) + assert_eq!(Semver::decl(), "type Semver = { version: string, }") } diff --git a/ts-rs/tests/serde-skip-with-default.rs b/ts-rs/tests/serde-skip-with-default.rs index 5f970af0b..bcb523ec3 100644 --- a/ts-rs/tests/serde-skip-with-default.rs +++ b/ts-rs/tests/serde-skip-with-default.rs @@ -20,8 +20,5 @@ pub struct Foobar { #[test] fn serde_skip_with_default() { - assert_eq!( - Foobar::decl(), - "type Foobar = { something_else: number, }" - ); + assert_eq!(Foobar::decl(), "type Foobar = { something_else: number, }"); } diff --git a/ts-rs/tests/slices.rs b/ts-rs/tests/slices.rs index 268a09096..0e396c515 100644 --- a/ts-rs/tests/slices.rs +++ b/ts-rs/tests/slices.rs @@ -21,7 +21,7 @@ fn slice_ref() { #[derive(TS)] struct Interface<'a> { #[allow(dead_code)] - a: &'a [&'a str] + a: &'a [&'a str], } assert_eq!(Interface::inline(), "{ a: Array, }") diff --git a/ts-rs/tests/struct_rename.rs b/ts-rs/tests/struct_rename.rs index aa7d78d9b..274b7a725 100644 --- a/ts-rs/tests/struct_rename.rs +++ b/ts-rs/tests/struct_rename.rs @@ -25,7 +25,10 @@ fn rename_all_camel_case() { alreadyCamelCase: i32, } - assert_eq!(Rename::inline(), "{ crc32cHash: number, b: number, alreadyCamelCase: number, }"); + assert_eq!( + Rename::inline(), + "{ crc32cHash: number, b: number, alreadyCamelCase: number, }" + ); } #[test]