Skip to content
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
8 changes: 7 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ fn check_token(token: proc_macro2::TokenTree, arg: &str) -> Option<String> {
// returns true.
.map_while(check_expression_is_path)
// Check if any yielded paths equal `arg`
.any(|expr_path| expr_path.path.segments[0].ident.to_string().eq(arg))
.any(|expr_path| {
if let Some(last) = expr_path.path.segments.last() {
last.ident.to_string().eq(arg)
} else {
false
}
})
// If so, return `Some(arg)`, otherwise `None`.
.then_some(arg.to_owned())
})
Expand Down
9 changes: 9 additions & 0 deletions test/issue-56/rust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[derive(serde_repr::Serialize_repr)]
#[repr(u16)]
#[tsync]
pub enum KeyCode {
Space = 32,
Apostrophe = 39,
Comma = 44,
Minus = 45,
}
8 changes: 8 additions & 0 deletions test/issue-56/tsync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

cd $SCRIPT_DIR

cargo run -- -i rust.rs -o typescript.d.ts
cargo run -- -i rust.rs -o typescript.ts
8 changes: 8 additions & 0 deletions test/issue-56/typescript.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* This file is generated and managed by tsync */

declare enum KeyCode {
Space = 32,
Apostrophe = 39,
Comma = 44,
Minus = 45,
}
8 changes: 8 additions & 0 deletions test/issue-56/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* This file is generated and managed by tsync */

export enum KeyCode {
Space = 32,
Apostrophe = 39,
Comma = 44,
Minus = 45,
}
1 change: 1 addition & 0 deletions test/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cd $SCRIPT_DIR
./issue-42-serde-rename/tsync.sh
./issue-43/tsync.sh
./issue-55/tsync.sh
./issue-56/tsync.sh
./issue-58/tsync.sh
./issue-60/tsync.sh
./issue-63/tsync.sh
Expand Down