Skip to content

Commit

Permalink
remove redundant dereferencing
Browse files Browse the repository at this point in the history
  • Loading branch information
Danue1 committed May 5, 2020
1 parent 54bac2d commit 2f32e62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum HangeulError {

impl fmt::Display for HangeulError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
match self {
HangeulError::JamoNotFound => write!(f, "HangeulError: Jamo not found"),
HangeulError::NotASyllable => write!(f, "HangeulError: Not correct Hangeul syllable"),
HangeulError::Uncomposable => write!(f, "HangeulError: Uncomposable"),
Expand All @@ -22,16 +22,14 @@ impl fmt::Display for HangeulError {

impl error::Error for HangeulError {
fn description(&self) -> &str {
match *self {
match self {
HangeulError::JamoNotFound => "HangeulError: Jamo not found",
HangeulError::NotASyllable => "HangeulError: Not a correct Hangeul syllable",
HangeulError::Uncomposable => "HangeulError: Uncomposable",
}
}

fn cause(&self) -> Option<&dyn error::Error> {
match *self {
_ => None
}
None
}
}
17 changes: 8 additions & 9 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl Choseong {
}

pub fn to_char(&self) -> char {
match *self {
match self {
Choseong::Giyeok => 'ㄱ',
Choseong::SsangGiyeok => 'ㄲ',
Choseong::Nieun => 'ㄴ',
Expand All @@ -141,7 +141,7 @@ impl Choseong {

impl Syllable for Choseong {
fn to_u32(&self) -> u32 {
match *self {
match self {
Choseong::Giyeok => 0x1100,
Choseong::SsangGiyeok => 0x1101,
Choseong::Nieun => 0x1102,
Expand Down Expand Up @@ -286,9 +286,8 @@ impl Jungseong {
}
}


pub fn to_char(&self) -> char {
match *self {
match self {
Jungseong::A => 'ㅏ',
Jungseong::AE => 'ㅐ',
Jungseong::YA => 'ㅑ',
Expand Down Expand Up @@ -316,7 +315,7 @@ impl Jungseong {

impl Syllable for Jungseong {
fn to_u32(&self) -> u32 {
match *self {
match self {
Jungseong::A => 0x1161,
Jungseong::AE => 0x1162,
Jungseong::YA => 0x1163,
Expand All @@ -342,7 +341,7 @@ impl Syllable for Jungseong {
}

fn composable_u32(&self) -> u32 {
let value = match *self {
let value = match self {
Jungseong::A => 0,
Jungseong::AE => 1,
Jungseong::YA => 2,
Expand Down Expand Up @@ -482,7 +481,7 @@ impl Jongseong {
}

pub fn to_char(&self) -> char {
match *self {
match self {
Jongseong::Giyeok => 'ㄱ',
Jongseong::SsangGiyeok => 'ㄲ',
Jongseong::GiyeokSiot => 'ㄳ',
Expand Down Expand Up @@ -516,7 +515,7 @@ impl Jongseong {

impl Syllable for Jongseong {
fn to_u32(&self) -> u32 {
match *self {
match self {
Jongseong::Giyeok => 0x11A8,
Jongseong::SsangGiyeok => 0x11A9,
Jongseong::GiyeokSiot => 0x11AA,
Expand Down Expand Up @@ -548,7 +547,7 @@ impl Syllable for Jongseong {
}

fn composable_u32(&self) -> u32 {
match *self {
match self {
Jongseong::Giyeok => 1,
Jongseong::SsangGiyeok => 2,
Jongseong::GiyeokSiot => 3,
Expand Down

0 comments on commit 2f32e62

Please sign in to comment.