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

Adding TryFromJs implementations for tuples #3843

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hansl
Copy link
Contributor

@hansl hansl commented May 9, 2024

This make it easier to get the first N values from an array when de-serializing.

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 50.79%. Comparing base (6ddc2b4) to head (52b1a0c).
Report is 173 commits behind head on main.

Files Patch % Lines
...engine/src/value/conversions/try_from_js/tuples.rs 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3843      +/-   ##
==========================================
+ Coverage   47.24%   50.79%   +3.54%     
==========================================
  Files         476      468       -8     
  Lines       46892    45281    -1611     
==========================================
+ Hits        22154    22999     +845     
+ Misses      24738    22282    -2456     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hansl
Copy link
Contributor Author

hansl commented May 9, 2024

No idea why the Windows action is failing.

@nekevss
Copy link
Member

nekevss commented May 11, 2024

If you rebase the CI should be fixed 😄 There was an issue that was fixed with #3845.

@nekevss nekevss requested a review from a team May 23, 2024 20:05
//! - If the tuple is longer than the array, the extra elements are `undefined`.
//! - If the array is empty, all elements are `undefined`.
//!
//! A tuple of size 0 (unit type) is represented as any value except `null` or `undefined`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit conflicted about this.

On the one hand, I think it makes sense to use any non-nullable value as the unit type, because undefined in JS is commonly used to represent the absence of a value, which () doesn't represent on the Rust world.
On the other hand, it would be a lot less surprising for new users to have it be undefined, since that's the default value for functions that don't return, which would be equivalent to how Rust functions return () when the function doesn't explicitly return.

I think I'm tending towards the second option, but I would be happy to know your thoughts on this.

@jedel1043 jedel1043 added enhancement New feature or request API labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants