Crates.io | braillepatterndots |
lib.rs | braillepatterndots |
version | 0.1.3 |
source | src |
created_at | 2020-07-11 09:07:05.050391 |
updated_at | 2020-07-11 11:26:08.34113 |
description | A simple crate for braille pattern |
homepage | https://github.com/yunseo-h68/braillePatternDots-rust |
repository | https://github.com/yunseo-h68/braillePatternDots-rust |
max_upload_size | |
id | 263968 |
size | 15,847 |
A simple crate for braille pattern
#[derive(Debug)]
pub struct Braille {
pub code: Vec<bool>,
pub character: char,
}
pub fn get_code(num: u32) -> Vec<bool>
When you pass Braille pattern dots number such as 123, 135, 123456 as parameter, it returns a Braille code in which the status of points is expressed in bool
use braillepatterndots::bpd;
let braille_code_135 : Vec<bool> = bpd::get_code(135);
// bpd::get_code(135) => [true, false, true, false, true, false]
assert_eq!(braille_code_135[0], true);
assert_eq!(braille_code_135[1], false);
assert_eq!(braille_code_135[2], true);
assert_eq!(braille_code_135[3], false);
assert_eq!(braille_code_135[4], true);
assert_eq!(braille_code_135[5], false);
pub fn get_char(num: u32) -> char
When you pass Braille pattern dots number such as 123, 135, 123456 as parameter, it returns a Braille character
use braillepatterndots::bpd;
let braille_char_145 : char = bpd::get_char(145);
assert_eq!(braille_char_145, '⠙');
pub fn get(num: u32) -> Braille
When you pass Braille pattern dots number such as 123, 135, 123456 as parameter, it returns a Braille structure.
use braillepatterndots::bpd;
let braille_124 = bpd::get(124);
assert_eq!(braille_124.character, '⠋');
assert_eq!(braille_124.code[0], true);
assert_eq!(braille_124.code[1], true);
assert_eq!(braille_124.code[2], false);
assert_eq!(braille_124.code[3], true);
assert_eq!(braille_124.code[4], false);
assert_eq!(braille_124.code[5], false);
pub fn gets(nums: Vec<u32>) -> Vec<Braille>
When you pass vector of Braille pattern dots number such as 123, 135, 123456 as parameter, it returns vector of Braille structure
use braillepatterndots::bpd;
use braillepatterndots::Braille;
let brailles : Vec<Braille> = bpd::gets(vec![135, 145, 124]);
// Braille pattern dots-135
assert_eq!(brailles[0].character, '⠕');
assert_eq!(brailles[0].code[0], true);
assert_eq!(brailles[0].code[1], false);
assert_eq!(brailles[0].code[2], true);
assert_eq!(brailles[0].code[3], false);
assert_eq!(brailles[0].code[4], true);
assert_eq!(brailles[0].code[5], false);
// Braille pattern dots-145
assert_eq!(brailles[1].character, '⠙');
assert_eq!(brailles[1].code[0], true);
assert_eq!(brailles[1].code[1], false);
assert_eq!(brailles[1].code[2], false);
assert_eq!(brailles[1].code[3], true);
assert_eq!(brailles[1].code[4], true);
assert_eq!(brailles[1].code[5], false);
// Braille pattern dots-124
assert_eq!(brailles[2].character, '⠋');
assert_eq!(brailles[2].code[0], true);
assert_eq!(brailles[2].code[1], true);
assert_eq!(brailles[2].code[2], false);
assert_eq!(brailles[2].code[3], true);
assert_eq!(brailles[2].code[4], false);
assert_eq!(brailles[2].code[5], false);
cargo test