-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully refactored the code to make it more rusty!
versions before 1.3.0 were mostly a rewrite of python library in rust, but in this version I tried to make it more rusty, it still can be a lot better, but its a job for other times. - we now store all different forms of a letter as a single character instead of old `&'static str` so thats a plus, although I used `\0` for showing empty character, we still have to see how it'll work out. - fully changed how `letters` work. - create a new module named `form` to store all the code related to form that is shared between different modules. we use enum now instead of const variables! - updated ligatures. - updated reshaper to use the new changes. - moved test outside of crate.
- Loading branch information
1 parent
76853f7
commit 7ccd659
Showing
12 changed files
with
1,495 additions
and
998 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/// Type of letters | ||
pub type LettersType = (char, Forms); | ||
|
||
/// Form of the letter | ||
#[derive(Clone, Copy, PartialEq, Eq)] | ||
#[repr(usize)] | ||
pub(crate) enum LetterForm { | ||
Isolated, | ||
Initial, | ||
Medial, | ||
Final, | ||
Unsupported, | ||
Unshaped, | ||
} | ||
|
||
/// The main type used to show letter form in each position | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub struct Forms { | ||
pub isolated: char, | ||
pub initial: char, | ||
pub medial: char, | ||
pub end: char, | ||
} | ||
|
||
impl Forms { | ||
pub const fn new(isolated: char, initial: char, medial: char, end: char) -> Self { | ||
Self { | ||
isolated, | ||
initial, | ||
medial, | ||
end, | ||
} | ||
} | ||
|
||
pub(crate) const fn get(&self, form: LetterForm) -> char { | ||
match form { | ||
LetterForm::Isolated => self.isolated, | ||
LetterForm::Initial => self.initial, | ||
LetterForm::Medial => self.medial, | ||
LetterForm::Final => self.end, | ||
_ => panic!("Unsupported Letter form"), | ||
} | ||
} | ||
} |
Oops, something went wrong.