Add a new Nullable<T> type that deserialize null to Nullable::<T>::Null#4325
Add a new Nullable<T> type that deserialize null to Nullable::<T>::Null#4325hansl merged 9 commits intoboa-dev:mainfrom
Nullable<T> type that deserialize null to Nullable::<T>::Null#4325Conversation
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
nekevss
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>.
There was a problem hiding this comment.
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
HalidOdat
left a comment
There was a problem hiding this comment.
Looks good just some minor nitpicky comment 😄
HalidOdat
left a comment
There was a problem hiding this comment.
Looks good to me! Just some minor nitpicks 😄
Now
Option<T>deserializesundefinedtoNone, but keepnullas deserialization for the inner type.This should clarify the API and distinguish between Nullable and Optional when dealing with JavaScript values in the host.