Rename Update::user -> Update::from

This commit is contained in:
Maybe Waffle 2023-02-13 14:08:50 +04:00
parent 430175278d
commit a411bff31c

View file

@ -29,7 +29,7 @@ pub struct Update {
} }
impl Update { impl Update {
// FIXME: rename user => from, add mentioned_users -> impl Iterator<&User> // FIXME: add mentioned_users -> impl Iterator<&User>
/// Returns the user that performed the action that caused this update, if /// Returns the user that performed the action that caused this update, if
/// known. /// known.
@ -37,7 +37,7 @@ impl Update {
/// This is generally the `from` field (except for `PollAnswer` where it's /// 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). /// `user` and `Poll` with `Error` which don't have such field at all).
#[must_use] #[must_use]
pub fn user(&self) -> Option<&User> { pub fn from(&self) -> Option<&User> {
use UpdateKind::*; use UpdateKind::*;
let from = match &self.kind { let from = match &self.kind {
@ -82,6 +82,11 @@ impl Update {
Some(chat) Some(chat)
} }
#[deprecated(note = "renamed to `from`", since = "0.13.0")]
pub fn user(&self) -> Option<&User> {
self.from()
}
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]