mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-31 16:40:37 +01:00
Make mentioned_users
somewhat less terrible
This commit is contained in:
parent
10846e19fd
commit
86a145e805
1 changed files with 27 additions and 8 deletions
|
@ -154,16 +154,35 @@ impl Update {
|
||||||
/// replies, pinned messages, message entities, "via bot" fields and more.
|
/// replies, pinned messages, message entities, "via bot" fields and more.
|
||||||
/// Also note that this function can return duplicate users.
|
/// Also note that this function can return duplicate users.
|
||||||
pub fn mentioned_users(&self) -> impl Iterator<Item = &User> {
|
pub fn mentioned_users(&self) -> impl Iterator<Item = &User> {
|
||||||
use either::Either::{Left, Right};
|
use either::Either::{Left as L, Right as R};
|
||||||
use std::iter::{empty, once};
|
use std::iter::{empty, once};
|
||||||
|
|
||||||
let i0 = Left;
|
// [root]
|
||||||
let i1 = |x| Right(Left(x));
|
// / \
|
||||||
let i2 = |x| Right(Right(Left(x)));
|
// left - / \ - right
|
||||||
let i3 = |x| Right(Right(Right(Left(x))));
|
// / \
|
||||||
let i4 = |x| Right(Right(Right(Right(Left(x)))));
|
// /\ /\
|
||||||
let i5 = |x| Right(Right(Right(Right(Right(Left(x))))));
|
// / \ / \
|
||||||
let i6 = |x| Right(Right(Right(Right(Right(Right(x))))));
|
// / \ / \
|
||||||
|
// 0 /\ /\ /\
|
||||||
|
// / \ / \ / \
|
||||||
|
// 1 2 3 4 5 6
|
||||||
|
//
|
||||||
|
// 0 = LL
|
||||||
|
// 1 = LRL
|
||||||
|
// 2 = LRR
|
||||||
|
// 3 = RLL
|
||||||
|
// 4 = RLR
|
||||||
|
// 5 = RRL
|
||||||
|
// 6 = RRR
|
||||||
|
|
||||||
|
let i0 = |x| L(L(x));
|
||||||
|
let i1 = |x| L(R(L(x)));
|
||||||
|
let i2 = |x| L(R(R(x)));
|
||||||
|
let i3 = |x| R(L(L(x)));
|
||||||
|
let i4 = |x| R(L(R(x)));
|
||||||
|
let i5 = |x| R(R(L(x)));
|
||||||
|
let i6 = |x| R(R(R(x)));
|
||||||
|
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
UpdateKind::Message(message)
|
UpdateKind::Message(message)
|
||||||
|
|
Loading…
Reference in a new issue