Fix clippy warnings
This commit is contained in:
parent
4e9784baf4
commit
8427eb082b
3 changed files with 9 additions and 14 deletions
|
@ -2,8 +2,7 @@ use wana_kana::{ConvertJapanese, IsJapaneseStr};
|
|||
|
||||
pub fn lookup(input: &str) -> Option<&jisho::Entry> {
|
||||
let input = input.trim();
|
||||
for word in jisho::lookup(input) {
|
||||
if
|
||||
jisho::lookup(input).into_iter().find(|&word| (
|
||||
// If input has no kanji,
|
||||
// we can just compare the input to the reading verbatim
|
||||
// ensuring both are hiragana
|
||||
|
@ -12,9 +11,5 @@ pub fn lookup(input: &str) -> Option<&jisho::Entry> {
|
|||
// is verbosely the same.
|
||||
// However, this will cause problems for some words.
|
||||
// For example, 照り焼き will be accepted but 照焼 won't.
|
||||
(input == word.kanji) {
|
||||
return Some(word);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
(input == word.kanji)))
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ pub use word::*;
|
|||
fn main() {
|
||||
const PORT: u16 = 8080;
|
||||
let mut server = Server::new(PORT)
|
||||
.expect(&format!("Failed to start server at port {PORT}"));
|
||||
.unwrap_or_else(|_| panic!("Failed to start server at port {PORT}"));
|
||||
server.run();
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ impl MessageResponseData {
|
|||
})
|
||||
}
|
||||
|
||||
fn to_response(self) -> MessageResponse {
|
||||
fn into_response(self) -> MessageResponse {
|
||||
MessageResponse {
|
||||
event: self.get_name(),
|
||||
data: self,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_message(self) -> Message {
|
||||
self.to_response().to_message()
|
||||
fn into_message(self) -> Message {
|
||||
self.into_response().to_message()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ impl Server {
|
|||
}
|
||||
|
||||
fn broadcast_player_count(&self) {
|
||||
let response = MessageResponseData::PlayerCount { players: self.clients.len() as u64 }.to_response();
|
||||
let response = MessageResponseData::PlayerCount { players: self.clients.len() as u64 }.into_response();
|
||||
for (_client, responder) in self.clients.iter() {
|
||||
responder.send(response.to_message());
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl Server {
|
|||
|
||||
fn handle_connection(&mut self, client_id: u64, responder: Responder) {
|
||||
println!("A client connected with id #{}", client_id);
|
||||
responder.send(MessageResponseData::Greeting { id: client_id }.to_message());
|
||||
responder.send(MessageResponseData::Greeting { id: client_id }.into_message());
|
||||
if let Some(ref last_response) = self.last_response {
|
||||
responder.send(last_response.to_message());
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl Server {
|
|||
message: String::from("Not in dictionary!"),
|
||||
},
|
||||
}
|
||||
}.to_response();
|
||||
}.into_response();
|
||||
|
||||
match response.data {
|
||||
// Send errors to only this client
|
||||
|
|
Loading…
Add table
Reference in a new issue