-
Notifications
You must be signed in to change notification settings - Fork 116
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
Convert fixed size Rust array to fixed size TS tuple #209
Convert fixed size Rust array to fixed size TS tuple #209
Conversation
By the way, @NyxCode, if this feature is not something you want, feel free to close the PR and I'll mark the corresponding issue as not planned |
Cool! A couple of points though:
|
|
You're right, that would be a massive TS file! What do you think a sensible limit would be?
I didn't realize that was the case, I saw they were converted into a struct with unnamed fields and just assumed they worked for every size, since I couldn't find a limit in
Do you mean keep the changes in |
This is due to a mistake I made: my |
One question: Can |
Playing around with this further is causing conflicts with generic inlining, I'm getting |
I think I got it, there's no way to resolve |
I fixed this, but if I remove the changes to |
I managed to remove the conversion to a tuple and resolve the generic inlining problem, still results in a separate case for the array though |
@@ -278,5 +278,6 @@ fn trait_bounds() { | |||
t: [T; N], | |||
} | |||
|
|||
assert_eq!(D::<&str, 41>::decl(), "type D<T> = { t: Array<T>, }") | |||
let ty = format!("type D<T> = {{ t: [{}], }}", "T, ".repeat(41).trim_end_matches(", ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I saw the 41 and I went "naaah" lol
This generics code always gives me a headache. Do you have an example of what exactly breaks with just the |
Yeah, so I'm not aware of any way to implement a trait for all homogeneous tuples of one type. If there was a spread syntax for tuples or something like that, i think it'd be possible to do it inductively/recursively, but there isnt. |
I also get confused a lot, proc macros are really hard to keep up with, but I get the following failing test:
|
Ah, okay, I think I (kinda) understand it now. Took me a bit to (again) understand how we hacked generics support into the lib ^^. That being said, this PR is strictly an improvement, so from my side, i'd be happy to merge this. Do you think it's ready, or is there something you'd still like to do? Great work, btw! Given the technical debt, I like where this ended up - doing most of the work in the |
I think it's ready to merge, as far as I can tell there is nothing else to add for this feature
Agreed, any refactor in this area of the code would be absolutely massive |
I dont disagree with that, though we're doing pretty weird stuff here. |
Fixes #137