Add UserId::{MIN, MAX} constants

This commit is contained in:
Maybe Waffle 2023-07-29 14:09:09 +04:00
parent 4ccf24c7ab
commit ae0451f7d7
3 changed files with 10 additions and 3 deletions

View file

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ThreadId` newtype over `MessageId`, used for identifying reply threads ([#887][pr887])
- `ChatId::as_user` ([#905][pr905])
- Implement `PartialEq<ChatId> for UserId` and `PartialEq<UserId> for ChatId` ([#905][pr905])
- `ChatId::{MIN, MAX}` ([#905][pr905])
[pr851]: https://github.com/teloxide/teloxide/pull/851
[pr887]: https://github.com/teloxide/teloxide/pull/887

View file

@ -107,8 +107,8 @@ const MIN_MARKED_CHANNEL_ID: i64 = -1997852516352;
const MAX_MARKED_CHANNEL_ID: i64 = -1000000000000;
const MIN_MARKED_CHAT_ID: i64 = MAX_MARKED_CHANNEL_ID + 1;
const MAX_MARKED_CHAT_ID: i64 = MIN_USER_ID - 1;
const MIN_USER_ID: i64 = 0;
const MAX_USER_ID: i64 = (1 << 40) - 1;
pub(crate) const MIN_USER_ID: i64 = 0;
pub(crate) const MAX_USER_ID: i64 = (1 << 40) - 1;
#[cfg(test)]
mod tests {

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::ChatId;
use crate::types::{ChatId, MAX_USER_ID, MIN_USER_ID};
/// Identifier of a user.
#[derive(Clone, Copy)]
@ -52,6 +52,12 @@ impl UserId {
self == TELEGRAM_USER_ID
}
/// The smallest user id that could possibly be returned by Telegram.
pub const MIN: Self = Self(MIN_USER_ID as u64);
/// The largest user id that could possibly be returned by Telegram.
pub const MAX: Self = Self(MAX_USER_ID as u64);
}
impl PartialEq<ChatId> for UserId {