mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 11:43:57 +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 {
|
impl InlineKeyboardMarkup {
|
||||||
pub fn new<I1, I2>(inline_keyboard: I1) -> Self
|
pub fn new<I1, I2>(inline_keyboard: I1) -> Self
|
||||||
where
|
where
|
||||||
I1: Into<Vec<I2>>,
|
I1: IntoIterator<Item = I2>,
|
||||||
I2: Into<Vec<InlineKeyboardButton>>,
|
I2: IntoIterator<Item = InlineKeyboardButton>,
|
||||||
{
|
{
|
||||||
Self {
|
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
|
pub fn inline_keyboard<I1, I2>(mut self, val: I1) -> Self
|
||||||
where
|
where
|
||||||
I1: Into<Vec<I2>>,
|
I1: IntoIterator<Item = I2>,
|
||||||
I2: Into<Vec<InlineKeyboardButton>>,
|
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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn append_row(mut self, buttons: Vec<InlineKeyboardButton>) -> Self {
|
pub fn append_row<R>(mut self, buttons: R) -> Self
|
||||||
self.inline_keyboard.push(buttons);
|
where
|
||||||
|
R: IntoIterator<Item = InlineKeyboardButton>,
|
||||||
|
{
|
||||||
|
self.inline_keyboard.push(buttons.into_iter().collect());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::types::{Message, User};
|
use crate::types::User;
|
||||||
|
|
||||||
/// This object represents one special entity in a text message.
|
/// This object represents one special entity in a text message.
|
||||||
///
|
///
|
||||||
|
|
|
@ -305,11 +305,11 @@ pub struct PassportElementErrorFiles {
|
||||||
impl PassportElementErrorFiles {
|
impl PassportElementErrorFiles {
|
||||||
pub fn new<S>(r#type: PassportElementErrorFilesType, file_hashes: S) -> Self
|
pub fn new<S>(r#type: PassportElementErrorFilesType, file_hashes: S) -> Self
|
||||||
where
|
where
|
||||||
S: Into<Vec<String>>,
|
S: IntoIterator<Item = String>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
r#type,
|
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
|
pub fn file_hashes<S>(mut self, val: S) -> Self
|
||||||
where
|
where
|
||||||
S: Into<Vec<String>>,
|
S: IntoIterator<Item = String>,
|
||||||
{
|
{
|
||||||
self.file_hashes = val.into();
|
self.file_hashes = val.into_iter().collect();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,11 +386,11 @@ pub struct PassportElementErrorTranslationFiles {
|
||||||
impl PassportElementErrorTranslationFiles {
|
impl PassportElementErrorTranslationFiles {
|
||||||
pub fn new<S>(r#type: PassportElementErrorTranslationFilesType, file_hashes: S) -> Self
|
pub fn new<S>(r#type: PassportElementErrorTranslationFilesType, file_hashes: S) -> Self
|
||||||
where
|
where
|
||||||
S: Into<Vec<String>>,
|
S: IntoIterator<Item = String>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
r#type,
|
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
|
pub fn file_hashes<S>(mut self, val: S) -> Self
|
||||||
where
|
where
|
||||||
S: Into<Vec<String>>,
|
S: IntoIterator<Item = String>,
|
||||||
{
|
{
|
||||||
self.file_hashes = val.into();
|
self.file_hashes = val.into_iter().collect();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,15 @@ pub struct ReplyKeyboardMarkup {
|
||||||
impl ReplyKeyboardMarkup {
|
impl ReplyKeyboardMarkup {
|
||||||
pub fn new<K1, K2>(keyboard: K1) -> Self
|
pub fn new<K1, K2>(keyboard: K1) -> Self
|
||||||
where
|
where
|
||||||
K1: Into<Vec<K2>>,
|
K1: IntoIterator<Item = K2>,
|
||||||
K2: Into<Vec<KeyboardButton>>,
|
K2: IntoIterator<Item = KeyboardButton>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
keyboard: keyboard.into().into_iter().map(Into::into).collect(),
|
keyboard: keyboard
|
||||||
|
.into_iter()
|
||||||
|
.map(<_>::into_iter)
|
||||||
|
.map(<_>::collect)
|
||||||
|
.collect(),
|
||||||
resize_keyboard: None,
|
resize_keyboard: None,
|
||||||
one_time_keyboard: None,
|
one_time_keyboard: None,
|
||||||
selective: None,
|
selective: None,
|
||||||
|
|
|
@ -22,12 +22,12 @@ impl ShippingOption {
|
||||||
where
|
where
|
||||||
S1: Into<String>,
|
S1: Into<String>,
|
||||||
S2: Into<String>,
|
S2: Into<String>,
|
||||||
P: Into<Vec<LabeledPrice>>,
|
P: IntoIterator<Item = LabeledPrice>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
title: title.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
|
pub fn prices<P>(mut self, val: P) -> Self
|
||||||
where
|
where
|
||||||
P: Into<Vec<LabeledPrice>>,
|
P: IntoIterator<Item = LabeledPrice>,
|
||||||
{
|
{
|
||||||
self.prices = val.into();
|
self.prices = val.into_iter().collect();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue