From 136852171eb5e5eb01c4435323d3e7cbf60f0298 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Wed, 14 Jun 2023 23:10:23 -0700 Subject: [PATCH] cargo fmt --- src/challenge.rs | 21 ++++++++++----------- src/kyujitai.rs | 8 ++++---- src/main.rs | 27 +++++++++++++++------------ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/challenge.rs b/src/challenge.rs index 2cc336b..2f5d073 100644 --- a/src/challenge.rs +++ b/src/challenge.rs @@ -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 = map .get("pos") diff --git a/src/kyujitai.rs b/src/kyujitai.rs index 1de0534..d90aad6 100644 --- a/src/kyujitai.rs +++ b/src/kyujitai.rs @@ -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 } diff --git a/src/main.rs b/src/main.rs index 3f15718..afaf37e 100644 --- a/src/main.rs +++ b/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());