Skip to content

Add a new Nullable<T> type that deserialize null to Nullable::<T>::Null#4325

Merged
hansl merged 9 commits intoboa-dev:mainfrom
hansl:nullable
Jul 9, 2025
Merged

Add a new Nullable<T> type that deserialize null to Nullable::<T>::Null#4325
hansl merged 9 commits intoboa-dev:mainfrom
hansl:nullable

Conversation

@hansl
Copy link
Contributor

@hansl hansl commented Jul 8, 2025

Now Option<T> deserializes undefined to None, but keep null as deserialization for the inner type.

This should clarify the API and distinguish between Nullable and Optional when dealing with JavaScript values in the host.

@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 24.52830% with 40 lines in your changes missing coverage. Please review.

Project coverage is 50.36%. Comparing base (6ddc2b4) to head (23efeee).
Report is 462 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/value/conversions/nullable/mod.rs 23.07% 40 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4325      +/-   ##
==========================================
+ Coverage   47.24%   50.36%   +3.12%     
==========================================
  Files         476      499      +23     
  Lines       46892    49945    +3053     
==========================================
+ Hits        22154    25156    +3002     
- Misses      24738    24789      +51     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hansl hansl requested a review from a team July 8, 2025 01:10
Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

Have some general feedback. It's looking pretty good overall! Had one thought about one of the APIs.

}

/// Returns `true` if this value is `Nullable::NotNull`.
pub const fn is_not_null(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

thought: this may be better as pub fn is<T: PartialEq>(&self)

is_not_null could also be expressed as !v.is_null(), so it seems like a duplicate API, but being able to compare the interior value could be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PartialEq is already implemented for it, so I don't think is is useful. I was trying to add the equivalent of is_some() and is_none() from Option<T>.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, oops. I didn't mean to leave the PartialEq in there. I meant more so like Gc::is.

Hmmmmm, maybe is_non_null if you were going for a is_some/is_none

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good just some minor nitpicky comment 😄

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just some minor nitpicks 😄

@hansl hansl enabled auto-merge July 9, 2025 00:01
@hansl hansl added this pull request to the merge queue Jul 9, 2025
Merged via the queue into boa-dev:main with commit e2247f3 Jul 9, 2025
16 checks passed
@hansl hansl deleted the nullable branch July 9, 2025 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants