mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Fixed problems with borrow checker in core/requests
This commit is contained in:
parent
5e57abf676
commit
8511aeb609
6 changed files with 16 additions and 20 deletions
|
@ -32,16 +32,14 @@ impl FormBuilder {
|
|||
where
|
||||
T: Serialize,
|
||||
{
|
||||
Self {
|
||||
form: value.map_or_else(
|
||||
|| self.form,
|
||||
|value| {
|
||||
self.form.text(
|
||||
match value {
|
||||
None => Self { form: self.form },
|
||||
Some(value) => Self {
|
||||
form: self.form.text(
|
||||
name.to_owned(),
|
||||
serde_json::to_string(value).expect("serde_json::to_string failed"),
|
||||
)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ impl Request for GetMe {
|
|||
type ReturnValue = User;
|
||||
|
||||
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> {
|
||||
Box::new(async {
|
||||
Box::new(async move {
|
||||
request(&self.info.client, &self.info.token, "getMe", None).await
|
||||
})
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ pub type RequestFuture<T> = Box<dyn Future<Output = T>>;
|
|||
|
||||
// todo: better name?
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RequestInfo {
|
||||
pub(crate) client: Client,
|
||||
pub(crate) token: String,
|
||||
pub struct RequestInfo {
|
||||
pub client: Client,
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
/// Unique identifier for the target chat or username of the target channel (in
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Request for SendMessage {
|
|||
|
||||
|
||||
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> {
|
||||
Box::new(async {
|
||||
Box::new(async move {
|
||||
let params = FormBuilder::new()
|
||||
.add("chat_id", &self.chat_id)
|
||||
.add("text", &self.text)
|
||||
|
|
|
@ -12,15 +12,15 @@ pub struct MessageEntity {
|
|||
#[derive(Deserialize, Debug, PartialEq, Hash, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "type")]
|
||||
enum MessageEntityKind {
|
||||
pub enum MessageEntityKind {
|
||||
Mention, Hashtag, Cashtag, BotCommand, Url, Email, PhoneNumber,
|
||||
Bold, Italic, Code, Pre,
|
||||
TextLink { url: String },
|
||||
TextMention { user: User }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test() {
|
||||
#[test]
|
||||
fn recursive_kind() {
|
||||
use serde_json::from_str;
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(async_await)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_more;
|
||||
#[macro_use]
|
||||
|
|
Loading…
Reference in a new issue