mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-11 04:21:12 +01:00
Merge pull request #189 from teloxide/with_payload
Add `HasPayload::with_payload_mut` function
This commit is contained in:
commit
961e5aef9d
2 changed files with 12 additions and 0 deletions
|
@ -10,8 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `WrongFileIdOrUrl` and `FailedToGetUrlContent` errors ([#188][pr188])
|
- `WrongFileIdOrUrl` and `FailedToGetUrlContent` errors ([#188][pr188])
|
||||||
|
- `HasPayload::with_payload_mut` function ([#189][pr189])
|
||||||
|
|
||||||
[pr188]: https://github.com/teloxide/teloxide-core/pull/188
|
[pr188]: https://github.com/teloxide/teloxide-core/pull/188
|
||||||
|
[pr189]: https://github.com/teloxide/teloxide-core/pull/189
|
||||||
|
|
||||||
## 0.4.3 - 2022-03-08
|
## 0.4.3 - 2022-03-08
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,16 @@ pub trait HasPayload {
|
||||||
|
|
||||||
/// Gain immutable access to the underlying payload.
|
/// Gain immutable access to the underlying payload.
|
||||||
fn payload_ref(&self) -> &Self::Payload;
|
fn payload_ref(&self) -> &Self::Payload;
|
||||||
|
|
||||||
|
/// Update payload with a function
|
||||||
|
fn with_payload_mut<F>(mut self, f: F) -> Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
F: FnOnce(&mut Self::Payload),
|
||||||
|
{
|
||||||
|
f(self.payload_mut());
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P> HasPayload for P
|
impl<P> HasPayload for P
|
||||||
|
|
Loading…
Reference in a new issue