- Add github actions CI
- Fix a few clippy lints
- Bump 3rd party dependencies
- Update cldr-numbers-full git submodule to commit b52a87048985d3052f12d30d05cfe5423ad92709
Locale::from_str
now supports underscore-delimited locales, e.g. "de_DE", in addition to previously supported dash-delimiated locales, e.g "de-DE"
Breaking changes:
- Because
SystemLocale
requires a lot of dependencies (especially for Windows users), it's now only available behind a feature flag (with-system-locale
). The upside is, of course, that those using num-format without this feature will only need to download and compile a small handful of dependencies.
Breaking changes:
Environment
was renamed toSystemLocale
.Error
andErrorKind
were refactored.- Compiling for Windows depends on bindgen and so requires Clang 3.9 or above.
Bug fixes:
- num-format now works on Windows!
Enhancements:
- Major overhaul of the code that interacts with operating systems (linux, macOS, freebsd, Windows, etc.)
- Methods
available_names
,from_name
, andname
were added to bothLocale
andSystemLocale
. - Several error messages now provide more detail about what exactly went wrong.
Bug fixes:
WriteFormatted
was being unconditionally implemented onstd::os::unix::net::UnixStream
, which is a unix-only type; so we moved this implementation behind a#[cfg(unix)]
flag.
Breaking changes:
-
Flatten module structure
- We decided to flatten the module structure of num-format to both improve code readabiity and to simplify the importing of types by users. Unfortunately this is a breaking change.
- The
num_format::format
andnum_format::errors
modules have been removed and all of their containing types have been moved to the crate root. - So whereas one used to do this:
use num_format::errors::{Error, ErrorKind}; use num_format::format::{CustomFormat, Environment, Format, Locale}; use num_format::format::utils::{InfinityStr, MinusSignStr, NanStr};
- one now does this:
use num_format::{CustomFormat, Environment, Error, ErrorKind, Format, Locale}; use num_format::utils::{InfinityStr, MinusSignStr, NanStr};
- Thank you BurntSushi for the suggestion
-
Refactor
Error
andErrorKind
- Since the future of the failure crate
is up in the air, we decided to remove it as a dependency, refactoring
num_format::Error
andnum_format::ErrorKind
to work with just plain oldstd::error::Error
- Thank you BurntSushi for the suggestion
- Since the future of the failure crate
is up in the air, we decided to remove it as a dependency, refactoring
New features:
-
impl
From<Environment>
andFrom<Locale>
forCustomFormat
- Now you can easiliy turn an
Environment
or aLocale
into aCustomFormat
; so it's easy to start with an already complete "base" format and then just tweak it slightly to the custom format you want.
use num_format::{CustomFormat, Error, Locale, ToFormattedString}; fn main() -> Result<(), Error> { let format = CustomFormat::from(Locale::en_IN) .into_builder() .separator(Some(' ')) .build()?; let s = 1_000_000.to_formatted_string(&format); assert_eq!(&s, "10 00 000"); Ok(()) }
- Now you can easiliy turn an
Initial release