algesten / ureq

A simple, safe HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change `send_json` `data` argument

k0nserv opened this issue · comments

Hello,

Request::send_json has the following signature:

    pub fn send_json(mut self, data: impl serde::Serialize) -> Result<Response>;

However, the implementation only ever uses references to data making the API less flexible than it could be. For example, I'm implementing some logic that needs to perform retries and because ownership is passed I need to clone my data, despite the function not needing ownership of it.

This would be a breaking change, although one that is trivially fixable, so it would need to be slated for 3.0. I'd also suggest reviewing all API surfaces for similar redundant passing of ownership and relaxing to references where appropriate.

Thanks!

Yeah I agree, this could be passed by reference. Can you make a bullet in FUTURE.md?

Can do!

Here's a PR #739