cargo fmt
This commit is contained in:
parent
8674adb1a5
commit
136852171e
3 changed files with 29 additions and 27 deletions
|
@ -4,7 +4,7 @@ use std::str::FromStr;
|
|||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_yaml::Value;
|
||||
|
||||
use crate::kyujitai::{Kyujitai, self};
|
||||
use crate::kyujitai::Kyujitai;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Challenge {
|
||||
|
@ -46,22 +46,16 @@ impl<'de> Deserialize<'de> for ChallengeWord {
|
|||
));
|
||||
};
|
||||
let text = map.get("text").map(|value| match value {
|
||||
Value::String(string) => vec![Furigana::new(
|
||||
string.clone(),
|
||||
None,
|
||||
)],
|
||||
Value::String(string) => vec![Furigana::new(string.clone(), None)],
|
||||
Value::Sequence(sequence) => sequence
|
||||
.iter()
|
||||
.map(|value| match value {
|
||||
Value::String(kanji) => Furigana::new(
|
||||
kanji.to_owned(),
|
||||
None,
|
||||
),
|
||||
Value::String(kanji) => Furigana::new(kanji.to_owned(), None),
|
||||
Value::Mapping(mapping) => {
|
||||
let (kanji, furigana) = mapping.iter().next().unwrap();
|
||||
Furigana::new(
|
||||
kanji.as_str().unwrap().to_owned(),
|
||||
Some(furigana.as_str().unwrap().to_owned())
|
||||
Some(furigana.as_str().unwrap().to_owned()),
|
||||
)
|
||||
}
|
||||
_ => panic!(),
|
||||
|
@ -79,7 +73,12 @@ impl<'de> Deserialize<'de> for ChallengeWord {
|
|||
}),
|
||||
_ => panic!("dictionary must be string!"),
|
||||
},
|
||||
None => text.as_ref().map(|furigana| furigana.iter().map(|segment| segment.kanji.clone()).collect()),
|
||||
None => text.as_ref().map(|furigana| {
|
||||
furigana
|
||||
.iter()
|
||||
.map(|segment| segment.kanji.clone())
|
||||
.collect()
|
||||
}),
|
||||
};
|
||||
let pos: Option<PartOfSpeech> = map
|
||||
.get("pos")
|
||||
|
|
|
@ -362,11 +362,11 @@ impl Kyujitai for String {
|
|||
'outer: for shinjitai in self.chars() {
|
||||
for (other_shinjitai, kyujitai) in KYUJITAI {
|
||||
if shinjitai == *other_shinjitai {
|
||||
output.push(kyujitai.clone());
|
||||
output.push(*kyujitai);
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
output.push(shinjitai.clone());
|
||||
output.push(shinjitai);
|
||||
}
|
||||
output
|
||||
}
|
||||
|
@ -376,11 +376,11 @@ impl Kyujitai for String {
|
|||
'outer: for kyujitai in self.chars() {
|
||||
for (shinjitai, other_kyujitai) in KYUJITAI {
|
||||
if kyujitai == *other_kyujitai {
|
||||
output.push(shinjitai.clone());
|
||||
output.push(*shinjitai);
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
output.push(kyujitai.clone());
|
||||
output.push(kyujitai);
|
||||
}
|
||||
output
|
||||
}
|
||||
|
|
27
src/main.rs
27
src/main.rs
|
@ -2,17 +2,17 @@
|
|||
extern crate rocket;
|
||||
|
||||
use core::panic;
|
||||
use rocket::fs::{relative, FileServer};
|
||||
use rocket::http::{Cookie, CookieJar};
|
||||
use rocket::request::{FlashMessage, FromRequest};
|
||||
use rocket::response::{Flash, Redirect};
|
||||
use rocket::{request, Request};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use sass_rocket_fairing::SassFairing;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::Infallible;
|
||||
use std::env;
|
||||
use rocket::fs::{FileServer, relative};
|
||||
use rocket::{Request, request};
|
||||
use rocket::http::{Cookie, CookieJar};
|
||||
use rocket::request::{FromRequest, FlashMessage};
|
||||
use rocket::response::{Redirect, Flash};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use std::fs;
|
||||
use sass_rocket_fairing::SassFairing;
|
||||
|
||||
mod challenge;
|
||||
use challenge::Challenge;
|
||||
|
@ -108,13 +108,16 @@ fn logout(cookies: &CookieJar<'_>, referer: Referer) -> Redirect {
|
|||
params.insert("token", token);
|
||||
params
|
||||
};
|
||||
match client.post("https://discord.com/api/oauth2/token/revoke")
|
||||
match client
|
||||
.post("https://discord.com/api/oauth2/token/revoke")
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.form(¶ms)
|
||||
.send().await {
|
||||
Ok(_) => println!("Successfully revoked token"),
|
||||
Err(error) => println!("Failed to revoke token: {:?}", error),
|
||||
};
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(_) => println!("Successfully revoked token"),
|
||||
Err(error) => println!("Failed to revoke token: {:?}", error),
|
||||
};
|
||||
});
|
||||
cookies.remove_private(Cookie::named(TOKEN_COOKIE));
|
||||
let redirect_url = referer.0.unwrap_or("/".to_owned());
|
||||
|
|
Loading…
Add table
Reference in a new issue