mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +01:00
Fix Clone
implementation for ErasedRequester
This commit is contained in:
parent
61d36e3ac9
commit
d3eb94b695
2 changed files with 15 additions and 1 deletions
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## unreleased
|
## 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
|
### Added
|
||||||
|
|
||||||
- `From<ApiError>`, `From<DownloadError>` and `From<std::io::Error>` impls for `RequestError` ([#241][pr241])
|
- `From<ApiError>`, `From<DownloadError>` and `From<std::io::Error>` impls for `RequestError` ([#241][pr241])
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// [`Requester`] with erased type.
|
/// [`Requester`] with erased type.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ErasedRequester<'a, E> {
|
pub struct ErasedRequester<'a, E> {
|
||||||
inner: Arc<dyn ErasableRequester<'a, Err = E> + 'a>,
|
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.
|
/// [`Request`] with erased type.
|
||||||
#[must_use = "Requests are lazy and do nothing unless sent"]
|
#[must_use = "Requests are lazy and do nothing unless sent"]
|
||||||
pub struct ErasedRequest<'a, T, E> {
|
pub struct ErasedRequest<'a, T, E> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue