Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Commit 8ef75c3

Browse files
committed
unwrap instead of matching none to null term
1 parent 135cadc commit 8ef75c3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const KANA_HI: u32 = 0x30FF;
1010

1111
fn print_usage(program: &str, opts: Options) {
1212
let usage = format!("Usage: {} [OPTIONS]", program);
13-
print!("{}", opts.usage(&usage));
13+
println!("{}", opts.usage(&usage));
1414
}
1515

1616
fn to_fw(c: char) -> Option<char> {
@@ -68,12 +68,9 @@ fn main() {
6868
output.push(char::from_u32(0x3000).unwrap()); // add a fw space to make kana look better
6969
let mut rng = thread_rng();
7070
while num_kata > 0 {
71-
let n: u32 = rng.gen_range(KANA_LO, KANA_HI + 1);
72-
let c = match char::from_u32(n) {
73-
Some(x) => x,
74-
None => '\0', // lol
75-
};
76-
output.push(c);
71+
output.push(char::from_u32(
72+
rng.gen_range(KANA_LO, KANA_HI + 1)).unwrap()
73+
);
7774
num_kata -= 1;
7875
}
7976
}

0 commit comments

Comments
 (0)