instruducing inner
data for Client to avoid extra Allocations
#641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
Related issue
What does this PR do?
Hello there, Thank your for your Library <3
this PR adds an extra object into the
Client
type, it wraps the inner content inside anArc
in order to avoid allocations when usingClone
. this is a simple and known pattern in Rust community.tho this can be done from outer scope where users could just simply wrap the
Client
itself inside anArc
, its a nice feature to have inside in case users forget about this case and accidentallyClone
theClient
without anArc
.this PR also includes an
impl
(perhaps it should be placed somewhere else, im not sure about the author's preference on this) to deref theClient
intoClientInner
. this allows us to user theself.
(the client ) normally just like before without needing to callself.inner
.also i added 2
.clone()
to the test to make them work normally. which i think is not really important.this PR should not introduce any breaking changes for users (neither for developers & contributors).
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!