Skip to content

Commit

Permalink
Add Decimal Numbers Symbol Set
Browse files Browse the repository at this point in the history
Fixes #42
  • Loading branch information
Shresht7 committed Oct 25, 2024
1 parent f13dc13 commit cf1833d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Config {
/// Valid Options:
/// - "Original" | "Normal" | "Katakana" -> Original Katakana Symbols (e.g. ア, カ, サ, ナ)
/// - "Binary" | "Bin" -> 0s and 1s
/// - "Decimal" | "Numbers" | "Digits" -> Decimal numbers from 0 to 9
/// - "Math" | "Maths" | "Mathematics" -> Mathematical Symbols (e.g. ∐, ∑, ≠, →)
/// - "ASCII" | "Text" | "English" -> ASCII Characters (from '!' to '~', including A-Z, a-z, 0-9 etc.)
/// - "Braille" | "Dots" -> Braille patterns (e.g ⠇, ⠾, ⣿)
Expand Down
8 changes: 8 additions & 0 deletions src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub enum Symbols {
Original,
/// Binary Symbols: Only `0` and `1`
Binary,
/// Decimal Numbers: From 0 to 9
Decimal,
/// ASCII Symbols: Printable characters from 33 to 126 (0x21 to 0x7E). (from '!' to '~', including A-Z, a-z, 0-9 etc.)
ASCII,
/// Mathematical Symbols: Various mathematical characters like: ∐, ∑, ≠, →
Expand All @@ -32,6 +34,7 @@ impl FromStr for Symbols {
match s.to_lowercase().as_str() {
"original" | "normal" | "katakana" => Ok(Self::Original),
"binary" | "bin" => Ok(Self::Binary),
"decimal" | "numbers" | "digits" => Ok(Self::Decimal),
"maths" | "math" | "mathematics" => Ok(Self::Math),
"ascii" | "text" | "english" => Ok(Self::ASCII),
"braille" | "dots" => Ok(Self::Braille),
Expand All @@ -55,6 +58,11 @@ impl Symbols {
return if r == 0 { '0' } else { '1' };
}

Self::Decimal => {
let r = utils::random_between(0, 10);
return std::char::from_digit(r, 10).unwrap_or('0');
}

Self::ASCII => {
let r = utils::random_between(33, 127) as u32;
return std::char::from_u32(r).unwrap_or('0');
Expand Down

0 comments on commit cf1833d

Please sign in to comment.