-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Implement new get_or_undefined
method for [JsValue]
#1492
Conversation
get_or_undefined
method for [JsValue]
(Clone
version)
get_or_undefined
method for [JsValue]
(Clone
version)get_or_undefined
method for [JsValue]
56f696b
to
ef48ac9
Compare
ef48ac9
to
c708233
Compare
Hmmm I'm not sure if the extra trait and code improves the ergonomic enough to stoping using well known standard library APIs and adding a new trait. I would like to know the thoughts of more people. |
If we are to do something like this I think returning a reference would be better, that way we would be reducing the number of clones. |
Completely understandable. I just wanted to point out that you can still use |
Let me try this. I tried to use a |
45340ce
to
5c96fc0
Compare
|
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.
I'm OK with the changes :) I though we might have a performance improvement, but not really.
Still, there's a lot of small improvements in performance. The last version using |
5c96fc0
to
6252b9b
Compare
6252b9b
to
96d7b6a
Compare
96d7b6a
to
4535aa2
Compare
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.
Looks good!
This Pull Request fixes/closes #1490.
It changes the following:
JsArgs
to add new methods to[JsValue]
get_or_undefined
for[JsValue]
args.get(n).cloned().unwrap_or_default()
withargs.get_or_undefined()
This should improve the usability of the api by not having to
unwrap_or_default
everytime we want an argument inside a builtin function.