Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-shigueo committed Jul 25, 2024
1 parent e08161c commit 61f1c9c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ When running `cargo test`, the TypeScript bindings will be exported to the file
| chrono-impl | Implement `TS` for types from *chrono* |
| bigdecimal-impl | Implement `TS` for types from *bigdecimal* |
| url-impl | Implement `TS` for types from *url* |
| uuid-impl | Implement `TS` for types from *uuid*
| uuid-impl | Implement `TS` for types from *uuid* |
| bson-uuid-impl | Implement `TS` for *bson::oid::ObjectId* and *bson::uuid* |
| bytes-impl | Implement `TS` for types from *bytes* |
| indexmap-impl | Implement `TS` for types from *indexmap* |
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 @@ -77,7 +77,7 @@
//! | chrono-impl | Implement `TS` for types from *chrono* |
//! | bigdecimal-impl | Implement `TS` for types from *bigdecimal* |
//! | url-impl | Implement `TS` for types from *url* |
//! | uuid-impl | Implement `TS` for types from *uuid*
//! | uuid-impl | Implement `TS` for types from *uuid* |
//! | bson-uuid-impl | Implement `TS` for *bson::oid::ObjectId* and *bson::uuid* |
//! | bytes-impl | Implement `TS` for types from *bytes* |
//! | indexmap-impl | Implement `TS` for types from *indexmap* |
Expand Down
10 changes: 8 additions & 2 deletions ts-rs/tests/integration/generics_flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ fn flattened_generic_parameters() {
}

assert_eq!(Item::<()>::decl(), "type Item<D> = { id: string, } & D;");
assert_eq!(TwoParameters::<(), ()>::decl(), "type TwoParameters<A, B> = { id: string, ab: [A, B], } & A & B;");
assert_eq!(Enum::<(), ()>::decl(), "type Enum<A, B> = { \"A\": A } | { \"B\": B } | { \"AB\": [A, B] };");
assert_eq!(
TwoParameters::<(), ()>::decl(),
"type TwoParameters<A, B> = { id: string, ab: [A, B], } & A & B;"
);
assert_eq!(
Enum::<(), ()>::decl(),
"type Enum<A, B> = { \"A\": A } | { \"B\": B } | { \"AB\": [A, B] };"
);
}
75 changes: 38 additions & 37 deletions ts-rs/tests/integration/issue_338.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
use std::collections::HashMap;
use ts_rs::TS;

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub struct MyType {
pub my_field_0: bool,
pub my_field_1: HashMap<MyEnum, MyStruct>,
}

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub enum MyEnum {
Variant0,
Variant1,
Variant2,
Variant3,
}

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub struct MyStruct {
pub my_field_0: bool,
pub my_field_1: u32,
pub my_field_2: Option<u32>,
pub my_field_3: Option<u32>,
pub my_field_4: Option<u32>,
pub my_field_5: String,
}

#[test]
fn test() {
assert_eq!(
MyType::inline(),
"{ my_field_0: boolean, my_field_1: { [key in MyEnum]?: MyStruct }, }"
);
}
use std::collections::HashMap;

use ts_rs::TS;

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub struct MyType {
pub my_field_0: bool,
pub my_field_1: HashMap<MyEnum, MyStruct>,
}

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub enum MyEnum {
Variant0,
Variant1,
Variant2,
Variant3,
}

#[derive(TS)]
#[ts(export, export_to = "issue_338/")]
pub struct MyStruct {
pub my_field_0: bool,
pub my_field_1: u32,
pub my_field_2: Option<u32>,
pub my_field_3: Option<u32>,
pub my_field_4: Option<u32>,
pub my_field_5: String,
}

#[test]
fn test() {
assert_eq!(
MyType::inline(),
"{ my_field_0: boolean, my_field_1: { [key in MyEnum]?: MyStruct }, }"
);
}

0 comments on commit 61f1c9c

Please sign in to comment.