Borrow self when try_clone and clone inner client. (#60)
Co-authored-by: Conrad Ludgate <conrad.ludgate@truelayer.com>pull/67/head
parent
07d154cadf
commit
2e57e95f99
|
@ -299,22 +299,18 @@ impl RequestBuilder {
|
||||||
client.execute_with_extensions(req, &mut extensions).await
|
client.execute_with_extensions(req, &mut extensions).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a request with initial [`Extensions`].
|
/// Attempt to clone the RequestBuilder.
|
||||||
#[deprecated = "use the with_extension method and send directly"]
|
///
|
||||||
pub async fn send_with_extensions(self, ext: &mut Extensions) -> Result<Response> {
|
/// `None` is returned if the RequestBuilder can not be cloned,
|
||||||
let Self { inner, client, .. } = self;
|
/// i.e. if the request body is a stream.
|
||||||
let req = inner.build()?;
|
///
|
||||||
client.execute_with_extensions(req, ext).await
|
/// # Extensions
|
||||||
}
|
/// Note that extensions are not preserved through cloning.
|
||||||
|
pub fn try_clone(&self) -> Option<Self> {
|
||||||
// TODO(conradludgate): fix this method to take `&self`. It's currently useless as it is.
|
|
||||||
// I'm tempted to make this breaking change without a major bump, but I'll wait for now
|
|
||||||
#[deprecated = "This method was badly replicated from the base RequestBuilder. If you somehow made use of this method, it will break next major version"]
|
|
||||||
pub fn try_clone(self) -> Option<Self> {
|
|
||||||
self.inner.try_clone().map(|inner| RequestBuilder {
|
self.inner.try_clone().map(|inner| RequestBuilder {
|
||||||
inner,
|
inner,
|
||||||
client: self.client,
|
client: self.client.clone(),
|
||||||
extensions: self.extensions,
|
extensions: Extensions::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue