Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo fmt #210

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions macros/src/types/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ pub(crate) fn r#enum_def(s: &ItemEnum) -> syn::Result<DerivedTS> {
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,
Expand Down Expand Up @@ -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 */ } }
Expand Down
2 changes: 1 addition & 1 deletion ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
//! - `heapless-impl`
//!
//! Implement `TS` for `Vec` from heapless
//!
//!
//! - `semver-impl`
//! Implement `TS` for `Version` from semver
//!
Expand Down
1 change: 0 additions & 1 deletion ts-rs/tests/enum_flattening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,3 @@ fn untagged() {
r#"{ a: number, a2: string, } | { b: boolean, } | { c: string, }"#
)
}

7 changes: 5 additions & 2 deletions ts-rs/tests/enum_struct_rename_all.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Serialize, Deserialize, TS, Clone)]
Expand All @@ -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, } }"#
)
}
5 changes: 1 addition & 4 deletions ts-rs/tests/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ fn default() {
struct B<U = Option<A<i32>>> {
u: U,
}
assert_eq!(
B::<()>::decl(),
"type B<U = A<number> | null> = { u: U, }"
);
assert_eq!(B::<()>::decl(), "type B<U = A<number> | null> = { u: U, }");
assert!(B::<()>::dependencies().iter().any(|dep| dep.ts_name == "A"));

#[derive(TS)]
Expand Down
5 changes: 1 addition & 4 deletions ts-rs/tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ fn list() {
data: Option<Vec<u32>>,
}

assert_eq!(
List::decl(),
"type List = { data: Array<number> | null, }"
);
assert_eq!(List::decl(), "type List = { data: Array<number> | null, }");
}
2 changes: 1 addition & 1 deletion ts-rs/tests/optional_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ts_rs::TS;
struct Optional {
#[ts(optional)]
a: Option<i32>,
b: Option<String>
b: Option<String>,
}

#[test]
Expand Down
6 changes: 4 additions & 2 deletions ts-rs/tests/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fn references() {
num_ref: &'a i32,
}

assert_eq!(FullOfRefs::inline(), "{ str_slice: string, ref_slice: Array<string>, num_ref: number, }")
assert_eq!(
FullOfRefs::inline(),
"{ str_slice: string, ref_slice: Array<string>, num_ref: number, }"
)
}

5 changes: 1 addition & 4 deletions ts-rs/tests/semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ fn semver() {
version: Version,
}

assert_eq!(
Semver::decl(),
"type Semver = { version: string, }"
)
assert_eq!(Semver::decl(), "type Semver = { version: string, }")
}
5 changes: 1 addition & 4 deletions ts-rs/tests/serde-skip-with-default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, }");
}
2 changes: 1 addition & 1 deletion ts-rs/tests/slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>, }")
Expand Down
5 changes: 4 additions & 1 deletion ts-rs/tests/struct_rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading