Skip to main content

Crate chislo

Crate chislo 

Source
Expand description

§chislo — числа прописью на русском языке

Convert numbers to Russian words (числа прописью) with correct grammatical gender and noun declension.

A Rust port of go-propisyu.

§Features

  • Integers up to i64::MAX (≈ 9.22 × 10^18); scale dictionary includes names up to 10^39
  • Three grammatical genders: masculine, feminine, neuter
  • Automatic Russian noun declension
  • Ordinal numbers (“первый”, “сорок второй”)
  • Currency formatting (“один рубль двадцать три копейки”)
  • Decimal number support with configurable precision
  • no_std compatible (with alloc)

§Quick start

use chislo::{int_to_words, int_to_words_gender, decline, ordinal, Gender};

assert_eq!(int_to_words(42), "сорок два");
assert_eq!(int_to_words_gender(1, Gender::Feminine), "одна");
assert_eq!(decline(5, "рубль", "рубля", "рублей"), "рублей");
assert_eq!(ordinal(42, Gender::Masculine), "сорок второй");

§Currency example

use chislo::{money, RUB};

assert_eq!(
    money(1234, 56, &RUB),
    "одна тысяча двести тридцать четыре рубля пятьдесят шесть копеек"
);

Structs§

Currency
GenderedNumber
A number with a chosen grammatical gender.
MoneyAmount
A currency amount ready for formatting.
Number
A number with no fixed representation yet. Call one of the .masculine(), .feminine(), .ordinal(...), .money(...) methods to get a Display-able wrapper.
NumberWithNoun
A number paired with noun declension forms (“5 рублей”).
OrdinalNumber
A number rendered as an ordinal (“сорок второй”).

Enums§

Error
Error type for number conversion.
Gender
Grammatical gender for Russian number words.
RoundingMode

Constants§

AED
BYN
CHF
CNY
EUR
GBP
JPY
KZT
RUB
UAH
USD

Functions§

date_to_words
Formats a full calendar date in Russian words (genitive day + month + year).
decimal_to_words
Converts a decimal number string to Russian words (2 decimal places).
decimal_to_words_precision
Converts a decimal string with specified precision (1-9 decimal places).
decimal_value_to_words
Converts a rust_decimal::Decimal value to Russian words (2 decimal places).
decimal_value_to_words_precision
Converts a rust_decimal::Decimal value with the specified precision (1-9).
decline
Returns the correct Russian noun declension form based on a number.
duration_from_core
Formats a core::time::Duration in Russian words (seconds precision).
duration_from_secs
Formats a duration given as a total number of seconds by splitting into days / hours / minutes / seconds.
duration_hms
Formats a duration given as hours, minutes, and seconds.
fraction
Formats an ordinary fraction with numerator and denominator as a Russian phrase like “одна вторая”, “три пятых”, “семь сотых”.
hours_word
Returns the Russian word form of “час/часа/часов” for the given count.
int_to_words
Converts an integer to Russian words using masculine gender.
int_to_words_gender
Converts an integer to Russian words with the specified grammatical gender.
minutes_word
Returns the Russian word form of “минута/минуты/минут” for the given count.
mixed_fraction
Formats a mixed number: “две целых одна треть” style (one whole + fraction).
money
Formats an amount as words with currency.
money_from_str
Parses an amount string and formats with currency.
money_from_str_rounded
Parses an amount string with the given rounding mode and formats it as words with the specified currency. Accepts both . and , as decimal separators.
month_name
Returns the Russian name of the month in the nominative case (e.g. “апрель”).
ordinal
Converts a number to its ordinal form in Russian.
percent
Formats an integer percentage with the correct declension.
percent_decimal
Formats a decimal percentage with 2 fractional places in Russian words.
percent_decimal_precision
Like percent_decimal but with a configurable precision (1–9 digits).
percent_word
Returns the noun form “процент / процента / процентов” for the given count, without the number itself. Useful when you already have the number formatted and only need the word.
seconds_word
Returns the Russian word form of “секунда/секунды/секунд” for the given count.
time_to_words
Formats wall-clock time in Russian words.
year_to_words
Formats a year in the genitive masculine case, as used in Russian dates (e.g. “две тысячи двадцать шестого” for 2026).