From 57d4743cf7b9d3736a7ecfec98d73a76e1ca69e3 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 26 Jun 2020 11:37:22 +0100 Subject: [PATCH] map docs --- README.org | 2 +- src/map.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index c3b30be..95744db 100644 --- a/README.org +++ b/README.org @@ -251,6 +251,6 @@ Notes: - It is valid for a single iterator to produce between 0 and 2 characters but no more. - If an input given to the algorithm that cannot be divided exactly into 16-bit blocks (i.e. one byte is left over), a padding byte of 0 is added as the 2nd byte to make it fit. - For more information see [[file:./src/mnemonic.rs][mnemonic.rs]]. + For more information see [[file:./src/mnemonic.rs][mnemonic.rs]] and [[file:./src/map.rs][map.rs]]. ** License GPL'd with love <3 diff --git a/src/map.rs b/src/map.rs index e10d75a..7c98d55 100644 --- a/src/map.rs +++ b/src/map.rs @@ -24,7 +24,7 @@ pub const KANA: &[char; 92] = &[ 'ヲ', //91 ]; -/// Valid kana for the +/// Valid kana for the first swap table pub const KANA_SWAP: &[Option; 92] = &[ None, None, None, None, None, //a Some('が'), Some('ぎ'), Some('ぐ'), Some('げ'), Some('ご'), //ka @@ -48,6 +48,7 @@ pub const KANA_SWAP: &[Option; 92] = &[ None, //wo (91) ]; +/// Valid kana for the 2nd swap table pub const KANA_SWAP2: &[Option; 92] = &[ None, None, None, None, None, //a None, None, None, None, None, //ka @@ -70,11 +71,14 @@ pub const KANA_SWAP2: &[Option; 92] = &[ None, None, None, None, None, //ya None, //wo (91) ]; + +/// Ranges for the sign0 test pub const KANA_SIGN: &[RangeInclusive; 2] = &[ 0..=45, 46..=91, ]; +/// Valid kana for the subscript pub const KANA_SUB: &[char; 18] = &[ 'ゃ', 'ゅ', @@ -90,6 +94,7 @@ pub const KANA_SUB: &[char; 18] = &[ use crate::def::Definition; +/// Valid ranges for the subscript from the kana table pub const KANA_SUB_VALID_FOR: &[Definition; 18] = &[ // Should we properly restrict these to only ones that make sense? (i.e. KI SHI HI etc..) Definition::single(5..=39), Definition::single(5..=39), @@ -148,7 +153,8 @@ pub fn sub(i: usize) -> Option<[Option; KANA_SUB.len()]> } } -pub fn sub_old(i: usize) -> Option> +/// Get all valid subs for kana at index `i`. +pub fn sub_all(i: usize) -> Option> { if i < KANA.len() { let mut output = Vec::with_capacity(KANA_SUB.len());