meilisearch-rust icon indicating copy to clipboard operation
meilisearch-rust copied to clipboard

instruducing `inner` data for Client to avoid extra Allocations

Open MrAliSalehi opened this issue 10 months ago • 0 comments

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 an Arc in order to avoid allocations when using Clone . 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 an Arc, its a nice feature to have inside in case users forget about this case and accidentally Clone the Client without an Arc.

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 the Client into ClientInner. this allows us to user the self. (the client ) normally just like before without needing to call self.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:

  • [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • [x] Have you read the contributing guidelines?
  • [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

MrAliSalehi avatar Feb 02 '25 15:02 MrAliSalehi