some formatting

This commit is contained in:
leca 2024-03-13 01:05:02 +03:00
parent d65978c891
commit a42744434d
1 changed files with 21 additions and 21 deletions

View File

@ -5,6 +5,7 @@ pub enum Kanas {
Hiragana,
Katakana
}
pub struct Hieroglyph {syllable: String, row: usize, column: usize}
impl std::fmt::Display for Hieroglyph {
@ -63,21 +64,21 @@ const KATAKANA: [[&str; 5]; 11] = [
pub fn get_kana_pair_for_hieroglyph(k: Kanas, h: &Hieroglyph) -> Hieroglyph {
match k {
Kanas::Hiragana => Hieroglyph{
syllable: HIRAGANA[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
Kanas::Katakana => Hieroglyph{
syllable: KATAKANA[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
Kanas::Romaji => Hieroglyph{
syllable: ROMAJI[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
Kanas::Hiragana => Hieroglyph {
syllable: HIRAGANA[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
Kanas::Katakana => Hieroglyph {
syllable: KATAKANA[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
Kanas::Romaji => Hieroglyph {
syllable: ROMAJI[h.row][h.column].to_string(),
row: h.row,
column: h.column
},
}
}
@ -85,13 +86,12 @@ pub fn generate_random_hieroglyph(k: Kanas) -> Hieroglyph {
let row: usize = rand::thread_rng().gen_range(0..ROMAJI.len()-1);
let column: usize = rand::thread_rng().gen_range(0..ROMAJI[0].len()-1);
let generated: String = {
match k {
Kanas::Romaji => ROMAJI[row][column].to_string(),
Kanas::Hiragana => HIRAGANA[row][column].to_string(),
Kanas::Katakana => KATAKANA[row][column].to_string()
}
let generated: String = match k {
Kanas::Romaji => ROMAJI[row][column].to_string(),
Kanas::Hiragana => HIRAGANA[row][column].to_string(),
Kanas::Katakana => KATAKANA[row][column].to_string()
};
if generated == "0" {
return generate_random_hieroglyph(k);
}