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

Add ref_* methods for Dynamic. #902

Closed
wants to merge 4 commits into from

Conversation

madonuko
Copy link

These methods does not take ownership and are easier to work with than their into_* counterparts.

These methods does not take ownership and are easier to work with than
their `into_*` counterparts.
@schungx
Copy link
Collaborator

schungx commented Jul 24, 2024

Can these be replaced by lock_read?

@schungx
Copy link
Collaborator

schungx commented Jul 26, 2024

Come to think of it and experimenting with a number of different names, I suggest as_XXX_ref and as_XXX_ref_mut in order to avoid conflicts with a deprecated API called as_immutable_string.

I have actually put together a PR here: #904

Would you wait until I commit this, then rebase your further changes on top of it?

@madonuko
Copy link
Author

Sure, I'm happy to wait. Also, why not as_XXX_mut (following rust std)?

@schungx
Copy link
Collaborator

schungx commented Jul 26, 2024

Sure, I'm happy to wait. Also, why not as_XXX_mut (following rust std)?

Hhhmmm... Good idea. I'll change.

@schungx
Copy link
Collaborator

schungx commented Jul 29, 2024

Changed in #905

@schungx
Copy link
Collaborator

schungx commented Jul 30, 2024

Is it necessary to keep the get_XXX versions since the only difference now is Option vs Result...

@madonuko
Copy link
Author

Well I guess the compiler can optimize the error handling away while compiling this crate?

@schungx
Copy link
Collaborator

schungx commented Jul 31, 2024

Well I guess the compiler can optimize the error handling away while compiling this crate?

Yes it can... but I'm not sure having get_string() would be significant better than as_immutable_string_ref().ok()... it is quite a bit shorter, true, but also very similar in API...

For others, get_array() and as_array_ref().ok() are not as pronounced in the length of the call...

@schungx
Copy link
Collaborator

schungx commented Aug 27, 2024

I would close this for the time being until later date when more API needs to be added.

@schungx schungx closed this Aug 27, 2024
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.

2 participants