pub struct HangulBlock {
pub initial: Jamo,
pub vowel: Jamo,
pub final_optional: Option<Jamo>,
}Expand description
A struct representing a composed Hangul syllable block, consisting of an initial Jamo, a vowel Jamo, and an optional final Jamo.
API:
use hangul_cd::block::{HangulBlock, HangulBlockDecompositionOptions};
use hangul_cd::jamo::{
Jamo,
JamoConsonantSingular,
JamoVowelSingular,
JamoUnicodeType,
};
// `HangulBlock`s can be directly constructed; to ensure validity,
// use a `BlockComposer` to build them instead. See `BlockComposer`
// documentation for more details.
let block = HangulBlock {
initial: Jamo::from_compatibility_jamo('ㄱ').unwrap(),
vowel: Jamo::from_compatibility_jamo('ㅏ').unwrap(),
final_optional: None,
};
// Convert the block to a Hangul syllable character
let syllable = block.to_char().unwrap();
assert_eq!(syllable, '가');
// Decompose the block into its constituent Jamo characters as a tuple
assert_eq!(
block.decomposed_tuple().unwrap(),
(Some(Jamo::Consonant(JamoConsonantSingular::Giyeok)),
None,
Some(Jamo::Vowel(JamoVowelSingular::A)),
None,
None,
None)
);
// Decompose the block into its constituent Jamo characters as a vector
let options = HangulBlockDecompositionOptions {
decompose_composites: false,
jamo_era: JamoUnicodeType::Modern,
};
let decomposed_vec = block.decomposed_vec(&options).unwrap();
assert_eq!(decomposed_vec, vec!['ᄀ', 'ᅡ']);Fields§
§initial: Jamo§vowel: Jamo§final_optional: Option<Jamo>Implementations§
Source§impl HangulBlock
impl HangulBlock
Sourcepub fn to_char(&self) -> Result<char, BlockError>
pub fn to_char(&self) -> Result<char, BlockError>
Converts the HangulBlock into a composed Hangul syllable unicode
character. Assumes all chars are valid Jamo.
Sourcepub fn from_char(c: char) -> Result<Self, BlockError>
pub fn from_char(c: char) -> Result<Self, BlockError>
Creates a HangulBlock from a composed Hangul syllable unicode character.
Sourcepub fn decomposed_tuple(&self) -> Result<DecomposedTuple, BlockError>
pub fn decomposed_tuple(&self) -> Result<DecomposedTuple, BlockError>
Decomposes the HangulBlock into its constituent Jamo characters.
Returns a tuple containing six Option<Jamo> values representing
the decomposed characters:
- First initial consonant
- Second initial consonant (if composite)
- First vowel
- Second vowel (if composite)
- First final consonant (if any)
- Second final consonant (if composite)
Sourcepub fn decomposed_vec(
&self,
options: &HangulBlockDecompositionOptions,
) -> Result<Vec<char>, BlockError>
pub fn decomposed_vec( &self, options: &HangulBlockDecompositionOptions, ) -> Result<Vec<char>, BlockError>
Decomposes the HangulBlock into its constituent Jamo characters
as a vector of chars, according to the specified decomposition options.
Trait Implementations§
Source§impl Debug for HangulBlock
impl Debug for HangulBlock
impl Eq for HangulBlock
Source§impl PartialEq for HangulBlock
impl PartialEq for HangulBlock
Source§fn eq(&self, other: &HangulBlock) -> bool
fn eq(&self, other: &HangulBlock) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HangulBlock
Auto Trait Implementations§
impl Freeze for HangulBlock
impl RefUnwindSafe for HangulBlock
impl Send for HangulBlock
impl Sync for HangulBlock
impl Unpin for HangulBlock
impl UnsafeUnpin for HangulBlock
impl UnwindSafe for HangulBlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more