Merge pull request #180 from teloxide/remove-language-code

Remove LanguageCode
This commit is contained in:
Temirkhan Myrzamadi 2020-02-24 21:35:13 +06:00 committed by GitHub
commit 863ea1f15e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 202 deletions

View file

@ -1,193 +0,0 @@
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LanguageCode {
AA,
AB,
AE,
AF,
AK,
AM,
AN,
AR,
AS,
AV,
AY,
AZ,
BA,
BE,
BG,
BH,
BI,
BM,
BN,
BO,
BR,
BS,
CA,
CE,
CH,
CO,
CR,
CS,
CU,
CV,
CY,
DA,
DE,
DV,
DZ,
EE,
EL,
EN,
EO,
ES,
ET,
EU,
FA,
FF,
FI,
FJ,
FO,
FR,
FY,
GA,
GD,
GL,
GN,
GU,
GV,
HA,
HE,
HI,
HO,
HR,
HT,
HU,
HY,
HZ,
IA,
ID,
IE,
IG,
II,
IK,
IO,
IS,
IT,
IU,
JA,
JV,
KA,
KG,
KI,
KJ,
KK,
KL,
KM,
KN,
KO,
KR,
KS,
KU,
KV,
KW,
KY,
LA,
LB,
LG,
LI,
LN,
LO,
LT,
LU,
LV,
MG,
MH,
MI,
MK,
ML,
MN,
MR,
MS,
MT,
MY,
NA,
NB,
ND,
NE,
NG,
NL,
NN,
NO,
NR,
NV,
NY,
OC,
OJ,
OM,
OR,
OS,
PA,
PI,
PL,
PS,
PT,
QU,
RM,
RN,
RO,
RU,
RW,
SA,
SC,
SD,
SE,
SG,
SI,
SK,
SL,
SM,
SN,
SO,
SQ,
SR,
SS,
ST,
SU,
SV,
SW,
TA,
TE,
TG,
TH,
TI,
TK,
TL,
TN,
TO,
TR,
TS,
TT,
TW,
TY,
UG,
UK,
UR,
UZ,
VE,
VI,
VO,
WA,
WO,
XH,
YI,
YO,
ZA,
ZH,
ZU,
#[serde(other)]
Other,
}

View file

@ -1,9 +1,7 @@
pub use country_code::*;
pub use currency::*;
pub use language_code::*;
pub use mime_wrapper::*;
mod country_code;
mod currency;
mod language_code;
mod mime_wrapper;

View file

@ -107,8 +107,8 @@ impl Update {
#[cfg(test)]
mod test {
use crate::types::{
Chat, ChatKind, ForwardKind, LanguageCode, MediaKind, Message,
MessageKind, Update, UpdateKind, User,
Chat, ChatKind, ForwardKind, MediaKind, Message, MessageKind, Update,
UpdateKind, User,
};
// TODO: more tests for deserialization
@ -158,7 +158,7 @@ mod test {
first_name: String::from("Waffle"),
last_name: None,
username: Some(String::from("WaffleLapkin")),
language_code: Some(LanguageCode::EN),
language_code: Some(String::from("en")),
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,

View file

@ -1,4 +1,3 @@
use crate::types::LanguageCode;
use serde::{Deserialize, Serialize};
/// This object represents a Telegram user or bot.
@ -25,7 +24,7 @@ pub struct User {
/// [IETF language tag] of the user's language.
///
/// [IETF language tag]: https://en.wikipedia.org/wiki/IETF_language_tag
pub language_code: Option<LanguageCode>,
pub language_code: Option<String>,
}
impl User {
@ -86,7 +85,7 @@ mod tests {
first_name: "firstName".to_string(),
last_name: Some("lastName".to_string()),
username: Some("Username".to_string()),
language_code: Some(LanguageCode::RU),
language_code: Some(String::from("ru")),
};
let actual = serde_json::from_str::<User>(&json).unwrap();
assert_eq!(actual, expected)

View file

@ -134,7 +134,7 @@ where
///
/// `prefix`: symbols, which denote start of a command.
///
/// Example:
/// ## Example
/// ```
/// use teloxide::utils::command::parse_command_with_prefix;
///