mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 03:43:22 +01:00
Replace Into<Vec<_>>
by IntoIterator<Item = _>
This commit is contained in:
parent
bd4dba3bf1
commit
0ef0526743
5 changed files with 39 additions and 24 deletions
|
@ -32,25 +32,36 @@ pub struct InlineKeyboardMarkup {
|
|||
impl InlineKeyboardMarkup {
|
||||
pub fn new<I1, I2>(inline_keyboard: I1) -> Self
|
||||
where
|
||||
I1: Into<Vec<I2>>,
|
||||
I2: Into<Vec<InlineKeyboardButton>>,
|
||||
I1: IntoIterator<Item = I2>,
|
||||
I2: IntoIterator<Item = InlineKeyboardButton>,
|
||||
{
|
||||
Self {
|
||||
inline_keyboard: inline_keyboard.into().into_iter().map(Into::into).collect(),
|
||||
inline_keyboard: inline_keyboard
|
||||
.into_iter()
|
||||
.map(<_>::into_iter)
|
||||
.map(<_>::collect)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inline_keyboard<I1, I2>(mut self, val: I1) -> Self
|
||||
where
|
||||
I1: Into<Vec<I2>>,
|
||||
I2: Into<Vec<InlineKeyboardButton>>,
|
||||
I1: IntoIterator<Item = I2>,
|
||||
I2: IntoIterator<Item = InlineKeyboardButton>,
|
||||
{
|
||||
self.inline_keyboard = val.into().into_iter().map(Into::into).collect();
|
||||
self.inline_keyboard = val
|
||||
.into_iter()
|
||||
.map(<_>::into_iter)
|
||||
.map(<_>::collect)
|
||||
.collect();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn append_row(mut self, buttons: Vec<InlineKeyboardButton>) -> Self {
|
||||
self.inline_keyboard.push(buttons);
|
||||
pub fn append_row<R>(mut self, buttons: R) -> Self
|
||||
where
|
||||
R: IntoIterator<Item = InlineKeyboardButton>,
|
||||
{
|
||||
self.inline_keyboard.push(buttons.into_iter().collect());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{Message, User};
|
||||
use crate::types::User;
|
||||
|
||||
/// This object represents one special entity in a text message.
|
||||
///
|
||||
|
|
|
@ -305,11 +305,11 @@ pub struct PassportElementErrorFiles {
|
|||
impl PassportElementErrorFiles {
|
||||
pub fn new<S>(r#type: PassportElementErrorFilesType, file_hashes: S) -> Self
|
||||
where
|
||||
S: Into<Vec<String>>,
|
||||
S: IntoIterator<Item = String>,
|
||||
{
|
||||
Self {
|
||||
r#type,
|
||||
file_hashes: file_hashes.into(),
|
||||
file_hashes: file_hashes.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,9 +320,9 @@ impl PassportElementErrorFiles {
|
|||
|
||||
pub fn file_hashes<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<Vec<String>>,
|
||||
S: IntoIterator<Item = String>,
|
||||
{
|
||||
self.file_hashes = val.into();
|
||||
self.file_hashes = val.into_iter().collect();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -386,11 +386,11 @@ pub struct PassportElementErrorTranslationFiles {
|
|||
impl PassportElementErrorTranslationFiles {
|
||||
pub fn new<S>(r#type: PassportElementErrorTranslationFilesType, file_hashes: S) -> Self
|
||||
where
|
||||
S: Into<Vec<String>>,
|
||||
S: IntoIterator<Item = String>,
|
||||
{
|
||||
Self {
|
||||
r#type,
|
||||
file_hashes: file_hashes.into(),
|
||||
file_hashes: file_hashes.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,9 +401,9 @@ impl PassportElementErrorTranslationFiles {
|
|||
|
||||
pub fn file_hashes<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<Vec<String>>,
|
||||
S: IntoIterator<Item = String>,
|
||||
{
|
||||
self.file_hashes = val.into();
|
||||
self.file_hashes = val.into_iter().collect();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,15 @@ pub struct ReplyKeyboardMarkup {
|
|||
impl ReplyKeyboardMarkup {
|
||||
pub fn new<K1, K2>(keyboard: K1) -> Self
|
||||
where
|
||||
K1: Into<Vec<K2>>,
|
||||
K2: Into<Vec<KeyboardButton>>,
|
||||
K1: IntoIterator<Item = K2>,
|
||||
K2: IntoIterator<Item = KeyboardButton>,
|
||||
{
|
||||
Self {
|
||||
keyboard: keyboard.into().into_iter().map(Into::into).collect(),
|
||||
keyboard: keyboard
|
||||
.into_iter()
|
||||
.map(<_>::into_iter)
|
||||
.map(<_>::collect)
|
||||
.collect(),
|
||||
resize_keyboard: None,
|
||||
one_time_keyboard: None,
|
||||
selective: None,
|
||||
|
|
|
@ -22,12 +22,12 @@ impl ShippingOption {
|
|||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
P: Into<Vec<LabeledPrice>>,
|
||||
P: IntoIterator<Item = LabeledPrice>,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
title: title.into(),
|
||||
prices: prices.into(),
|
||||
prices: prices.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ impl ShippingOption {
|
|||
|
||||
pub fn prices<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<LabeledPrice>>,
|
||||
P: IntoIterator<Item = LabeledPrice>,
|
||||
{
|
||||
self.prices = val.into();
|
||||
self.prices = val.into_iter().collect();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue