pub struct Bot {
pub request: RequestHandle,
pub handlers: HashMap<String, UnboundedSender<(RequestHandle, Message)>>,
pub unknown_handler: Option<UnboundedSender<(RequestHandle, Message)>>,
pub callback_handler: Option<UnboundedSender<(RequestHandle, CallbackQuery)>>,
pub inline_handler: Option<UnboundedSender<(RequestHandle, InlineQuery)>>,
/* private fields */
}Expand description
The main bot structure
Contains all configuration like key, name, etc. important handles to message the user and
request to issue requests to the Telegram server
Fields§
§request: RequestHandle§handlers: HashMap<String, UnboundedSender<(RequestHandle, Message)>>§unknown_handler: Option<UnboundedSender<(RequestHandle, Message)>>§callback_handler: Option<UnboundedSender<(RequestHandle, CallbackQuery)>>§inline_handler: Option<UnboundedSender<(RequestHandle, InlineQuery)>>Implementations§
Source§impl Bot
impl Bot
Sourcepub fn new(key: &str) -> Bot
pub fn new(key: &str) -> Bot
Examples found in repository?
More examples
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_self")
13 .and_then(|(bot, msg)| {
14 bot.document(msg.chat.id)
15 .file("examples/send_self.rs")
16 .send()
17 })
18 .for_each(|_| Ok(()));
19
20 // enter the main loop
21 bot.run_with(handle);
22}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 // Register a reply command which answers a message
13 let handle = bot.new_cmd("/reply")
14 .and_then(|(bot, msg)| {
15 let mut text = msg.text.unwrap().clone();
16 if text.is_empty() {
17 text = "<empty>".into();
18 }
19
20 bot.message(msg.chat.id, text).send()
21 })
22 .for_each(|_| Ok(()));
23
24 bot.run_with(handle);
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let known = bot.new_cmd("/known")
13 .and_then(|(bot, msg)| bot.message(msg.chat.id, "This one is known".into()).send())
14 .for_each(|_| Ok(()));
15
16 // Every possible command is unknown
17 let unknown = bot.unknown_cmd()
18 .and_then(|(bot, msg)| bot.message(msg.chat.id, "Unknown command".into()).send())
19 .for_each(|_| Ok(()));
20
21 // Enter the main loop
22 bot.run_with(known.join(unknown));
23}6fn main() {
7 // Create the bot
8 let bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
9
10 let stream = bot.get_stream(None).for_each(|(_, msg)| {
11 println!("Received: {:#?}", msg);
12
13 Ok(())
14 });
15
16 // enter the main loop
17 tokio::run(stream.into_future().map_err(|_| ()));
18 /*let res = lp.run(stream.for_each(|_| Ok(())).into_future());
19 if let Err(err) = res {
20 eprintln!("Event loop shutdown:");
21 for (i, cause) in err.iter_causes().enumerate() {
22 eprintln!(" => {}: {}", i, cause);
23 }
24 }*/
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_mediagroup")
13 .and_then(|(bot, msg)| {
14 bot.mediagroup(msg.chat.id)
15 .file(File::Url("https://upload.wikimedia.org/wikipedia/commons/f/f4/Honeycrisp.jpg".into()))
16 .file(File::Url("https://upload.wikimedia.org/wikipedia/en/3/3e/Pooh_Shepard1928.jpg".into()))
17 .file("examples/bee.jpg")
18 .send()
19 })
20 .for_each(|_| Ok(()));
21
22 // enter the main loop
23 bot.run_with(handle);
24}Sourcepub fn update_interval(self, interval: u64) -> Bot
pub fn update_interval(self, interval: u64) -> Bot
Sets the update interval to an integer in milliseconds
Examples found in repository?
More examples
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_self")
13 .and_then(|(bot, msg)| {
14 bot.document(msg.chat.id)
15 .file("examples/send_self.rs")
16 .send()
17 })
18 .for_each(|_| Ok(()));
19
20 // enter the main loop
21 bot.run_with(handle);
22}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 // Register a reply command which answers a message
13 let handle = bot.new_cmd("/reply")
14 .and_then(|(bot, msg)| {
15 let mut text = msg.text.unwrap().clone();
16 if text.is_empty() {
17 text = "<empty>".into();
18 }
19
20 bot.message(msg.chat.id, text).send()
21 })
22 .for_each(|_| Ok(()));
23
24 bot.run_with(handle);
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let known = bot.new_cmd("/known")
13 .and_then(|(bot, msg)| bot.message(msg.chat.id, "This one is known".into()).send())
14 .for_each(|_| Ok(()));
15
16 // Every possible command is unknown
17 let unknown = bot.unknown_cmd()
18 .and_then(|(bot, msg)| bot.message(msg.chat.id, "Unknown command".into()).send())
19 .for_each(|_| Ok(()));
20
21 // Enter the main loop
22 bot.run_with(known.join(unknown));
23}6fn main() {
7 // Create the bot
8 let bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
9
10 let stream = bot.get_stream(None).for_each(|(_, msg)| {
11 println!("Received: {:#?}", msg);
12
13 Ok(())
14 });
15
16 // enter the main loop
17 tokio::run(stream.into_future().map_err(|_| ()));
18 /*let res = lp.run(stream.for_each(|_| Ok(())).into_future());
19 if let Err(err) = res {
20 eprintln!("Event loop shutdown:");
21 for (i, cause) in err.iter_causes().enumerate() {
22 eprintln!(" => {}: {}", i, cause);
23 }
24 }*/
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_mediagroup")
13 .and_then(|(bot, msg)| {
14 bot.mediagroup(msg.chat.id)
15 .file(File::Url("https://upload.wikimedia.org/wikipedia/commons/f/f4/Honeycrisp.jpg".into()))
16 .file(File::Url("https://upload.wikimedia.org/wikipedia/en/3/3e/Pooh_Shepard1928.jpg".into()))
17 .file("examples/bee.jpg")
18 .send()
19 })
20 .for_each(|_| Ok(()));
21
22 // enter the main loop
23 bot.run_with(handle);
24}Sourcepub fn new_cmd(
&mut self,
cmd: &str,
) -> impl Stream<Item = (RequestHandle, Message), Error = Error>
pub fn new_cmd( &mut self, cmd: &str, ) -> impl Stream<Item = (RequestHandle, Message), Error = Error>
Creates a new command and returns a stream which will yield a message when the command is send
Examples found in repository?
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_self")
13 .and_then(|(bot, msg)| {
14 bot.document(msg.chat.id)
15 .file("examples/send_self.rs")
16 .send()
17 })
18 .for_each(|_| Ok(()));
19
20 // enter the main loop
21 bot.run_with(handle);
22}More examples
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 // Register a reply command which answers a message
13 let handle = bot.new_cmd("/reply")
14 .and_then(|(bot, msg)| {
15 let mut text = msg.text.unwrap().clone();
16 if text.is_empty() {
17 text = "<empty>".into();
18 }
19
20 bot.message(msg.chat.id, text).send()
21 })
22 .for_each(|_| Ok(()));
23
24 bot.run_with(handle);
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let known = bot.new_cmd("/known")
13 .and_then(|(bot, msg)| bot.message(msg.chat.id, "This one is known".into()).send())
14 .for_each(|_| Ok(()));
15
16 // Every possible command is unknown
17 let unknown = bot.unknown_cmd()
18 .and_then(|(bot, msg)| bot.message(msg.chat.id, "Unknown command".into()).send())
19 .for_each(|_| Ok(()));
20
21 // Enter the main loop
22 bot.run_with(known.join(unknown));
23}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_mediagroup")
13 .and_then(|(bot, msg)| {
14 bot.mediagroup(msg.chat.id)
15 .file(File::Url("https://upload.wikimedia.org/wikipedia/commons/f/f4/Honeycrisp.jpg".into()))
16 .file(File::Url("https://upload.wikimedia.org/wikipedia/en/3/3e/Pooh_Shepard1928.jpg".into()))
17 .file("examples/bee.jpg")
18 .send()
19 })
20 .for_each(|_| Ok(()));
21
22 // enter the main loop
23 bot.run_with(handle);
24}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let text = r"
13Dearest creature in creation,
14Study English pronunciation.
15I will teach you in my verse
16Sounds like corpse, corps, horse, and worse.
17I will keep you, Suzy, busy,
18Make your head with heat grow dizzy.
19Tear in eye, your dress will tear.
20So shall I! Oh hear my prayer.
21
22Just compare heart, beard, and heard,
23Dies and diet, lord and word,
24Sword and sward, retain and Britain.
25(Mind the latter, how it's written.)
26Now I surely will not plague you
27With such words as plaque and ague.
28But be careful how you speak:
29Say break and steak, but bleak and streak;
30Cloven, oven, how and low,
31Script, receipt, show, poem, and toe.
32
33Hear me say, devoid of trickery,
34Daughter, laughter, and Terpsichore,
35Typhoid, measles, topsails, aisles,
36Exiles, similes, and reviles;
37Scholar, vicar, and cigar,
38Solar, mica, war and far;
39One, anemone, Balmoral,
40Kitchen, lichen, laundry, laurel;
41Gertrude, German, wind and mind,
42Scene, Melpomene, mankind.
43
44...";
45
46 let handle = bot.new_cmd("/send")
47 .and_then(move |(bot, msg)| {
48 bot.document(msg.chat.id)
49 .file(("poem.txt", text.as_bytes()))
50 .caption("The Chaos")
51 .send()
52 })
53 .for_each(|_| Ok(()));
54
55 // enter the main loop
56 bot.run_with(handle);
57}10fn main() {
11 // Create the bot
12 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
13
14 // Register a location command which will send a location to requests like /location 2.321 12.32
15 enum LocationErr {
16 Telegram(Error),
17 WrongLocationFormat,
18 }
19
20 let handle = bot.new_cmd("/location")
21 .then(|result| {
22 let (bot, mut msg) = result.expect("Strange telegram error!");
23
24 if let Some(pos) = msg.text.take() {
25 let mut elms = pos.split_whitespace().take(2).filter_map(
26 |x| x.parse::<f32>().ok(),
27 );
28
29 if let (Some(a), Some(l)) = (elms.next(), elms.next()) {
30 return Ok((bot, msg, a, l));
31 }
32 }
33
34 return Err((bot, msg, LocationErr::WrongLocationFormat));
35 })
36 .and_then(|(bot, msg, long, alt)| {
37 bot.location(msg.chat.id, long, alt).send().map_err(|err| {
38 (bot, msg, LocationErr::Telegram(err))
39 })
40 })
41 .or_else(|(bot, msg, err)| {
42 let text = {
43 match err {
44 LocationErr::Telegram(err) => format!("Telegram error: {:?}", err),
45 LocationErr::WrongLocationFormat => "Couldn't parse the location!".into(),
46 }
47 };
48
49 bot.message(msg.chat.id, text).send()
50 })
51 .for_each(|_| Ok(()));
52
53 // Register a get_my_photo command which will send the own profile photo to the chat
54 enum PhotoErr {
55 Telegram(Error),
56 NoPhoto,
57 }
58
59 let handle2 = bot.new_cmd("/get_my_photo")
60 .then(|result| {
61 let (bot, msg) = result.expect("Strange telegram error!");
62
63 let user_id = msg.from.clone().unwrap().id;
64
65 bot.get_user_profile_photos(user_id)
66 .limit(1u32)
67 .send()
68 .then(|result| match result {
69 Ok((bot, photos)) => {
70 if photos.total_count == 0 {
71 return Err((bot, msg, PhotoErr::NoPhoto));
72 }
73
74 return Ok((bot, msg, photos.photos[0][0].clone().file_id));
75 }
76 Err(err) => Err((bot, msg, PhotoErr::Telegram(err))),
77 })
78 })
79 .and_then(|(bot, msg, file_id)| {
80 bot.photo(msg.chat.id)
81 .file(File::Telegram(file_id))
82 .send()
83 .map_err(|err| (bot, msg, PhotoErr::Telegram(err)))
84 })
85 .or_else(|(bot, msg, err)| {
86 let text = match err {
87 PhotoErr::Telegram(err) => format!("Telegram Error: {:?}", err),
88 PhotoErr::NoPhoto => "No photo exists!".into(),
89 };
90
91 bot.message(msg.chat.id, text).send()
92 })
93 .for_each(|_| Ok(()));
94
95 // enter the main loop
96 bot.run_with(handle.join(handle2));
97}Sourcepub fn unknown_cmd(
&mut self,
) -> impl Stream<Item = (RequestHandle, Message), Error = Error>
pub fn unknown_cmd( &mut self, ) -> impl Stream<Item = (RequestHandle, Message), Error = Error>
Returns a stream which will yield a message when none of previously registered commands matches
Examples found in repository?
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let known = bot.new_cmd("/known")
13 .and_then(|(bot, msg)| bot.message(msg.chat.id, "This one is known".into()).send())
14 .for_each(|_| Ok(()));
15
16 // Every possible command is unknown
17 let unknown = bot.unknown_cmd()
18 .and_then(|(bot, msg)| bot.message(msg.chat.id, "Unknown command".into()).send())
19 .for_each(|_| Ok(()));
20
21 // Enter the main loop
22 bot.run_with(known.join(unknown));
23}Sourcepub fn callback(
&mut self,
) -> impl Stream<Item = (RequestHandle, CallbackQuery), Error = Error>
pub fn callback( &mut self, ) -> impl Stream<Item = (RequestHandle, CallbackQuery), Error = Error>
Returns a stream which will yield a received CallbackQuery
Sourcepub fn inline(
&mut self,
) -> impl Stream<Item = (RequestHandle, InlineQuery), Error = Error>
pub fn inline( &mut self, ) -> impl Stream<Item = (RequestHandle, InlineQuery), Error = Error>
Returns a stream which will yield a received CallbackQuery
Examples found in repository?
10fn main() {
11 // Create the bot
12 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
13
14 let stream = bot.inline()
15 .and_then(|(bot, query)| {
16 let result: Vec<Box<dyn Serialize + Send>> = vec![
17 Box::new(
18 InlineQueryResultArticle::new(
19 "Test".into(),
20 Box::new(input_message_content::Text::new("This is a test".into())),
21 ).reply_markup(InlineKeyboardMarkup::new(vec![
22 vec![
23 InlineKeyboardButton::new("Wikipedia".into())
24 .url("http://wikipedia.org"),
25 ],
26 ])),
27 ),
28 ];
29
30 bot.answer_inline_query(query.id, result)
31 .is_personal(true)
32 .send()
33 })
34 .for_each(|_| Ok(()));
35
36 // enter the main loop
37 bot.run_with(stream);
38 //tokio::spawn(stream.into_future().map_err(|_| ()));
39
40 //lp.run(stream.for_each(|_| Ok(())).into_future()).unwrap();
41}pub fn resolve_name(&self) -> impl Future<Item = Option<String>, Error = Error>
pub fn process_updates( self, last_id: Arc<AtomicUsize>, ) -> impl Stream<Item = (RequestHandle, Update), Error = Error>
Sourcepub fn get_stream(
self,
name: Option<String>,
) -> impl Stream<Item = (RequestHandle, Update), Error = Error>
pub fn get_stream( self, name: Option<String>, ) -> impl Stream<Item = (RequestHandle, Update), Error = Error>
The main update loop, the update function is called every update_interval milliseconds When an update is available the last_id will be updated and the message is filtered for commands The message is forwarded to the returned stream if no command was found
Examples found in repository?
6fn main() {
7 // Create the bot
8 let bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
9
10 let stream = bot.get_stream(None).for_each(|(_, msg)| {
11 println!("Received: {:#?}", msg);
12
13 Ok(())
14 });
15
16 // enter the main loop
17 tokio::run(stream.into_future().map_err(|_| ()));
18 /*let res = lp.run(stream.for_each(|_| Ok(())).into_future());
19 if let Err(err) = res {
20 eprintln!("Event loop shutdown:");
21 for (i, cause) in err.iter_causes().enumerate() {
22 eprintln!(" => {}: {}", i, cause);
23 }
24 }*/
25}pub fn into_future(&self) -> impl Future<Item = (), Error = Error>
Sourcepub fn run_with<I>(self, other: I)where
I: IntoFuture<Error = Error>,
<I as IntoFuture>::Future: Send + 'static,
<I as IntoFuture>::Item: Send,
pub fn run_with<I>(self, other: I)where
I: IntoFuture<Error = Error>,
<I as IntoFuture>::Future: Send + 'static,
<I as IntoFuture>::Item: Send,
Examples found in repository?
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_self")
13 .and_then(|(bot, msg)| {
14 bot.document(msg.chat.id)
15 .file("examples/send_self.rs")
16 .send()
17 })
18 .for_each(|_| Ok(()));
19
20 // enter the main loop
21 bot.run_with(handle);
22}More examples
8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 // Register a reply command which answers a message
13 let handle = bot.new_cmd("/reply")
14 .and_then(|(bot, msg)| {
15 let mut text = msg.text.unwrap().clone();
16 if text.is_empty() {
17 text = "<empty>".into();
18 }
19
20 bot.message(msg.chat.id, text).send()
21 })
22 .for_each(|_| Ok(()));
23
24 bot.run_with(handle);
25}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let known = bot.new_cmd("/known")
13 .and_then(|(bot, msg)| bot.message(msg.chat.id, "This one is known".into()).send())
14 .for_each(|_| Ok(()));
15
16 // Every possible command is unknown
17 let unknown = bot.unknown_cmd()
18 .and_then(|(bot, msg)| bot.message(msg.chat.id, "Unknown command".into()).send())
19 .for_each(|_| Ok(()));
20
21 // Enter the main loop
22 bot.run_with(known.join(unknown));
23}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let handle = bot.new_cmd("/send_mediagroup")
13 .and_then(|(bot, msg)| {
14 bot.mediagroup(msg.chat.id)
15 .file(File::Url("https://upload.wikimedia.org/wikipedia/commons/f/f4/Honeycrisp.jpg".into()))
16 .file(File::Url("https://upload.wikimedia.org/wikipedia/en/3/3e/Pooh_Shepard1928.jpg".into()))
17 .file("examples/bee.jpg")
18 .send()
19 })
20 .for_each(|_| Ok(()));
21
22 // enter the main loop
23 bot.run_with(handle);
24}10fn main() {
11 // Create the bot
12 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
13
14 let stream = bot.inline()
15 .and_then(|(bot, query)| {
16 let result: Vec<Box<dyn Serialize + Send>> = vec![
17 Box::new(
18 InlineQueryResultArticle::new(
19 "Test".into(),
20 Box::new(input_message_content::Text::new("This is a test".into())),
21 ).reply_markup(InlineKeyboardMarkup::new(vec![
22 vec![
23 InlineKeyboardButton::new("Wikipedia".into())
24 .url("http://wikipedia.org"),
25 ],
26 ])),
27 ),
28 ];
29
30 bot.answer_inline_query(query.id, result)
31 .is_personal(true)
32 .send()
33 })
34 .for_each(|_| Ok(()));
35
36 // enter the main loop
37 bot.run_with(stream);
38 //tokio::spawn(stream.into_future().map_err(|_| ()));
39
40 //lp.run(stream.for_each(|_| Ok(())).into_future()).unwrap();
41}8fn main() {
9 // Create the bot
10 let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12 let text = r"
13Dearest creature in creation,
14Study English pronunciation.
15I will teach you in my verse
16Sounds like corpse, corps, horse, and worse.
17I will keep you, Suzy, busy,
18Make your head with heat grow dizzy.
19Tear in eye, your dress will tear.
20So shall I! Oh hear my prayer.
21
22Just compare heart, beard, and heard,
23Dies and diet, lord and word,
24Sword and sward, retain and Britain.
25(Mind the latter, how it's written.)
26Now I surely will not plague you
27With such words as plaque and ague.
28But be careful how you speak:
29Say break and steak, but bleak and streak;
30Cloven, oven, how and low,
31Script, receipt, show, poem, and toe.
32
33Hear me say, devoid of trickery,
34Daughter, laughter, and Terpsichore,
35Typhoid, measles, topsails, aisles,
36Exiles, similes, and reviles;
37Scholar, vicar, and cigar,
38Solar, mica, war and far;
39One, anemone, Balmoral,
40Kitchen, lichen, laundry, laurel;
41Gertrude, German, wind and mind,
42Scene, Melpomene, mankind.
43
44...";
45
46 let handle = bot.new_cmd("/send")
47 .and_then(move |(bot, msg)| {
48 bot.document(msg.chat.id)
49 .file(("poem.txt", text.as_bytes()))
50 .caption("The Chaos")
51 .send()
52 })
53 .for_each(|_| Ok(()));
54
55 // enter the main loop
56 bot.run_with(handle);
57}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bot
impl !RefUnwindSafe for Bot
impl Send for Bot
impl Sync for Bot
impl Unpin for Bot
impl !UnwindSafe for Bot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more