Fix Clone implementation for ErasedRequester

This commit is contained in:
Maybe Waffle 2022-08-19 06:05:25 +04:00
parent 61d36e3ac9
commit d3eb94b695
2 changed files with 15 additions and 1 deletions

View file

@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## unreleased
### Fixed
- `ErasedRequester<E>` now implements `Clone` even if `E` is not `Clone` ([#244][pr244])
[pr244]: https://github.com/teloxide/teloxide-core/pull/244
### Added
- `From<ApiError>`, `From<DownloadError>` and `From<std::io::Error>` impls for `RequestError` ([#241][pr241])

View file

@ -10,7 +10,6 @@ use crate::{
};
/// [`Requester`] with erased type.
#[derive(Clone)]
pub struct ErasedRequester<'a, E> {
inner: Arc<dyn ErasableRequester<'a, Err = E> + 'a>,
}
@ -37,6 +36,15 @@ impl<E> std::fmt::Debug for ErasedRequester<'_, E> {
}
}
// NB. hand-written impl to avoid `E: Clone` bound
impl<E> Clone for ErasedRequester<'_, E> {
fn clone(&self) -> Self {
Self {
inner: Arc::clone(&self.inner),
}
}
}
/// [`Request`] with erased type.
#[must_use = "Requests are lazy and do nothing unless sent"]
pub struct ErasedRequest<'a, T, E> {