From 8baf8af8c13b2900f66f5934db28863ec5fa43fb Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 3 Feb 2023 16:41:14 +0400 Subject: [PATCH] Document `Update::{user, chat}` --- crates/teloxide-core/src/types/update.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/teloxide-core/src/types/update.rs b/crates/teloxide-core/src/types/update.rs index b05343f2..7cd59ff6 100644 --- a/crates/teloxide-core/src/types/update.rs +++ b/crates/teloxide-core/src/types/update.rs @@ -29,6 +29,13 @@ pub struct Update { } impl Update { + // FIXME: rename user => from, add mentioned_users -> impl Iterator<&User> + + /// Returns the user that performed the action that caused this update, if + /// known. + /// + /// This is generally the `from` field (except for `PollAnswer` where it's + /// `user` and `Poll` with `Error` which don't have such field at all). #[must_use] pub fn user(&self) -> Option<&User> { use UpdateKind::*; @@ -52,6 +59,7 @@ impl Update { Some(from) } + /// Returns the chat in which is update has happened, if any. #[must_use] pub fn chat(&self) -> Option<&Chat> { use UpdateKind::*;