diff --git a/CHANGELOG b/CHANGELOG index 2bc98a51..decde501 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,11 +12,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Additional trait impls for `f16` and `bf16` to better match Rust's interface. - Added `Options::buffer_size_const` for integer and float writers. - Added `build_checked` and `build_unchecked` to our `NumberFormatBuilder` API. +- Added `build_checked` to our `Options` API. ### Changed - Lowered the MSRV from 1.63.0 to 1.61.0 and adds support for most testing on 1.61.0. - Reduced the required buffer size for integer and float writers when using `buffer_size` and `buffer_size_const` for decimal numbers. +- Deprecated `NumberFormatBuilder::build` due to a lack of validation. +- Deprecated `Options::set_*` in our write float API since options should be considered immutable. ## [1.0.5] 2024-12-08 diff --git a/lexical-util/src/feature_format.rs b/lexical-util/src/feature_format.rs index 18c0d670..ffa3440f 100644 --- a/lexical-util/src/feature_format.rs +++ b/lexical-util/src/feature_format.rs @@ -2779,9 +2779,9 @@ pub const SAGE_STRING: u128 = NumberFormatBuilder::new() .build_strict(); // JSON [456] -/// Number format for a [`JSON`] literal floating-point number. +/// Number format for a [`JSON`][`JSON-REF`] literal floating-point number. /// -/// [`JSON`]: https://www.json.org/json-en.html +/// [`JSON-REF`]: https://www.json.org/json-en.html #[rustfmt::skip] pub const JSON: u128 = NumberFormatBuilder::new() .required_digits(true) @@ -2792,9 +2792,9 @@ pub const JSON: u128 = NumberFormatBuilder::new() .build_strict(); // TOML [34569AB] -/// Number format for a [`TOML`] literal floating-point number. +/// Number format for a [`TOML`][`TOML-REF`] literal floating-point number. /// -/// [`TOML`]: https://toml.io/en/ +/// [`TOML-REF`]: https://toml.io/en/ #[rustfmt::skip] pub const TOML: u128 = NumberFormatBuilder::new() .digit_separator(num::NonZeroU8::new(b'_')) @@ -2806,15 +2806,15 @@ pub const TOML: u128 = NumberFormatBuilder::new() .build_strict(); // YAML (defined in-terms of JSON schema). -/// Number format for a [`YAML`] literal floating-point number. +/// Number format for a [`YAML`][`YAML-REF`] literal floating-point number. /// -/// [`YAML`]: https://yaml.org/ +/// [`YAML-REF`]: https://yaml.org/ pub const YAML: u128 = JSON; // XML [01234578MN] -/// Number format for a [`XML`] literal floating-point number. +/// Number format for an [`XML`][`XML-REF`] literal floating-point number. /// -/// [`XML`]: https://en.wikipedia.org/wiki/XML +/// [`XML-REF`]: https://en.wikipedia.org/wiki/XML #[rustfmt::skip] pub const XML: u128 = NumberFormatBuilder::new() .required_exponent_digits(false) diff --git a/lexical-util/src/format.rs b/lexical-util/src/format.rs index 02a2c43d..ff061cd3 100644 --- a/lexical-util/src/format.rs +++ b/lexical-util/src/format.rs @@ -320,10 +320,10 @@ - [`ZIG_STRING`]: Number format to parse a [`Zig`] float from string. - [`SAGE_LITERAL`]: Number format for a [`Sage`] literal floating-point number. - [`SAGE_STRING`]: Number format to parse a [`Sage`] float from string. -- [`JSON`]: Number format for a [`JSON`] literal floating-point number. -- [`TOML`]: Number format for a [`TOML`] literal floating-point number. -- [`YAML`]: Number format for a [`YAML`] literal floating-point number. -- [`XML`]: Number format for a [`XML`] literal floating-point number. +- [`JSON`]: Number format for a [`JSON`][`JSON-REF`] literal floating-point number. +- [`TOML`]: Number format for a [`TOML`][`TOML-REF`] literal floating-point number. +- [`YAML`]: Number format for a [`YAML`][`YAML-REF`] literal floating-point number. +- [`XML`]: Number format for an [`XML`][`XML-REF`] literal floating-point number. - [`SQLITE`]: Number format for a [`SQLite`] literal floating-point number. - [`POSTGRESQL`]: Number format for a [`PostgreSQL`] literal floating-point number. - [`MYSQL`]: Number format for a [`MySQL`] literal floating-point number. @@ -616,10 +616,10 @@ [`Matlab`]: https://www.mathworks.com/products/matlab.html [`Zig`]: https://ziglang.org/ [`Sage`]: https://www.sagemath.org/ -[`JSON`]: https://www.json.org/json-en.html -[`TOML`]: https://toml.io/en/ -[`YAML`]: https://yaml.org/ -[`XML`]: https://en.wikipedia.org/wiki/XML +[`JSON-REF`]: https://www.json.org/json-en.html +[`TOML-REF`]: https://toml.io/en/ +[`YAML-REF`]: https://yaml.org/ +[`XML-REF`]: https://en.wikipedia.org/wiki/XML [`SQLite`]: https://www.sqlite.org/ [`PostgreSQL`]: https://www.postgresql.org/ [`MySQL`]: https://www.mysql.com/ diff --git a/lexical-write-float/src/lib.rs b/lexical-write-float/src/lib.rs index 13de8b7b..b92d59a4 100644 --- a/lexical-write-float/src/lib.rs +++ b/lexical-write-float/src/lib.rs @@ -31,22 +31,7 @@ //! //! With the default options, using [`FORMATTED_SIZE_DECIMAL`] //! guarantees the buffer will be large enough to write the digits for all -//! numbers of that type. In addition, `digits` is guaranteed to start at the -//! same address as `buffer`, that is: -//! -//! ```rust -//! # use core::str; -//! use lexical_write_integer::{FormattedSize, ToLexical}; -//! -//! let mut buffer = [0u8; u64::FORMATTED_SIZE_DECIMAL]; -//! let digits = 1234u64.to_lexical(&mut buffer); -//! assert_eq!(str::from_utf8(digits), Ok("1234")); -//! -//! // NOTE: This is done for demonstration: don't use this in real code. -//! let digits_ptr = digits.as_ptr(); -//! let buffer_ptr = buffer.as_ptr(); -//! assert_eq!(digits_ptr, buffer_ptr); -//! ``` +//! numbers of that type. //! //! [`FORMATTED_SIZE_DECIMAL`]: FormattedSize::FORMATTED_SIZE_DECIMAL //! diff --git a/lexical-write-float/src/options.rs b/lexical-write-float/src/options.rs index 17b3cb71..f15da56a 100644 --- a/lexical-write-float/src/options.rs +++ b/lexical-write-float/src/options.rs @@ -3,9 +3,156 @@ //! This enables extensive control over how the float is written, from //! control characters like the decimal point, to the use of exponent //! notation, and the number of significant digits. - -// TODO: Need to document the pre-defined variants -// TODO: Add in the references to the languages available here +//! +//! # Examples +//! +//! For example, to customize the writing of numbers for new exponent +//! and decimal point characters, you would use [`Options`] to create +//! a custom format and write the integer using the format. +//! +//! ```rust +//! # use core::{num, str}; +//! +//! use lexical_write_float::{FormattedSize, Options, ToLexicalWithOptions}; +//! use lexical_write_float::format::STANDARD; +//! +//! let value = 1.234e45f64; +//! +//! const CUSTOM: Options = Options::builder() +//! // write exponents as "1.2^10" and not "1.2e10" +//! .exponent(b'^') +//! // use the European decimal point, so "1,2" and not "1.2" +//! .decimal_point(b',') +//! .build_strict(); +//! +//! const BYTES: usize = CUSTOM.buffer_size_const::(); +//! let mut buffer = [0u8; BYTES]; +//! let digits = value.to_lexical_with_options::(&mut buffer, &CUSTOM); +//! assert_eq!(str::from_utf8(digits), Ok("1,234^45")); +//! ``` +//! +//! # Pre-Defined Formats +//! +//! These are the pre-defined formats for parsing numbers from various +//! programming, markup, and data languages. +//! +//! - [`STANDARD`]: Standard number format. +//! - [`DECIMAL_COMMA`]: Numerical format with a decimal comma. +//! - [`HEX_FLOAT`]: Numerical format for hexadecimal floats, which use a `p` exponent. +//! - [`CARAT_EXPONENT`]: Numerical format where `^` is used as the exponent notation character. +//! - [`RUST_LITERAL`]: Number format for a [`Rust`] literal floating-point number. +//! - [`PYTHON_LITERAL`]: Number format for a [`Python`] literal floating-point number. +//! - [`CXX_LITERAL`]: Number format for a [`C++`] literal floating-point number. +//! - [`C_LITERAL`]: Number format for a [`C`] literal floating-point number. +//! - [`RUBY_LITERAL`]: Number format for a [`Ruby`] literal floating-point number. +//! - [`RUBY_STRING`]: Number format to parse a [`Ruby`] float from string. +//! - [`SWIFT_LITERAL`]: Number format for a [`Swift`] literal floating-point number. +//! - [`GO_LITERAL`]: Number format for a [`Golang`] literal floating-point number. +//! - [`HASKELL_LITERAL`]: Number format for a [`Haskell`] literal floating-point number. +//! - [`HASKELL_STRING`]: Number format to parse a [`Haskell`] float from string. +//! - [`JAVASCRIPT_LITERAL`]: Number format for a [`Javascript`] literal floating-point number. +//! - [`JAVASCRIPT_STRING`]: Number format to parse a [`Javascript`] float from string. +//! - [`PERL_LITERAL`]: Number format for a [`Perl`] literal floating-point number. +//! - [`PHP_LITERAL`]: Number format for a [`PHP`] literal floating-point number. +//! - [`JAVA_LITERAL`]: Number format for a [`Java`] literal floating-point number. +//! - [`JAVA_STRING`]: Number format to parse a [`Java`] float from string. +//! - [`R_LITERAL`]: Number format for an [`R`] literal floating-point number. +//! - [`KOTLIN_LITERAL`]: Number format for a [`Kotlin`] literal floating-point number. +//! - [`KOTLIN_STRING`]: Number format to parse a [`Kotlin`] float from string. +//! - [`JULIA_LITERAL`]: Number format for a [`Julia`] literal floating-point number. +//! - [`CSHARP_LITERAL`]: Number format for a [`C#`] literal floating-point number. +//! - [`CSHARP_STRING`]: Number format to parse a [`C#`] float from string. +//! - [`KAWA_LITERAL`]: Number format for a [`Kawa`] literal floating-point number. +//! - [`KAWA_STRING`]: Number format to parse a [`Kawa`] float from string. +//! - [`GAMBITC_LITERAL`]: Number format for a [`Gambit-C`] literal floating-point number. +//! - [`GAMBITC_STRING`]: Number format to parse a [`Gambit-C`] float from string. +//! - [`GUILE_LITERAL`]: Number format for a [`Guile`] literal floating-point number. +//! - [`GUILE_STRING`]: Number format to parse a [`Guile`] float from string. +//! - [`CLOJURE_LITERAL`]: Number format for a [`Clojure`] literal floating-point number. +//! - [`CLOJURE_STRING`]: Number format to parse a [`Clojure`] float from string. +//! - [`ERLANG_LITERAL`]: Number format for an [`Erlang`] literal floating-point number. +//! - [`ERLANG_STRING`]: Number format to parse an [`Erlang`] float from string. +//! - [`ELM_LITERAL`]: Number format for an [`Elm`] literal floating-point number. +//! - [`ELM_STRING`]: Number format to parse an [`Elm`] float from string. +//! - [`SCALA_LITERAL`]: Number format for a [`Scala`] literal floating-point number. +//! - [`SCALA_STRING`]: Number format to parse a [`Scala`] float from string. +//! - [`ELIXIR_LITERAL`]: Number format for an [`Elixir`] literal floating-point number. +//! - [`ELIXIR_STRING`]: Number format to parse an [`Elixir`] float from string. +//! - [`FORTRAN_LITERAL`]: Number format for a [`FORTRAN`] literal floating-point number. +//! - [`D_LITERAL`]: Number format for a [`D`] literal floating-point number. +//! - [`COFFEESCRIPT_LITERAL`]: Number format for a [`Coffeescript`] literal floating-point number. +//! - [`COFFEESCRIPT_STRING`]: Number format to parse a [`Coffeescript`] float from string. +//! - [`COBOL_LITERAL`]: Number format for a [`COBOL`] literal floating-point number. +//! - [`COBOL_STRING`]: Number format to parse a [`COBOL`] float from string. +//! - [`FSHARP_LITERAL`]: Number format for an [`F#`] literal floating-point number. +//! - [`VB_LITERAL`]: Number format for a [`Visual Basic`] literal floating-point number. +//! - [`VB_STRING`]: Number format to parse a [`Visual Basic`] float from string. +//! - [`OCAML_LITERAL`]: Number format for an [`OCaml`] literal floating-point number. +//! - [`OBJECTIVEC_LITERAL`]: Number format for an [`Objective-C`] literal floating-point number. +//! - [`OBJECTIVEC_STRING`]: Number format to parse an [`Objective-C`] float from string. +//! - [`REASONML_LITERAL`]: Number format for an [`ReasonML`] literal floating-point number. +//! - [`MATLAB_LITERAL`]: Number format for a [`MATLAB`] literal floating-point number. +//! - [`ZIG_LITERAL`]: Number format for a [`Zig`] literal floating-point number. +//! - [`SAGE_LITERAL`]: Number format for a [`Sage`] literal floating-point number. +//! - [`JSON`]: Number format for a [`JSON`][`JSON-REF`] literal floating-point number. +//! - [`TOML`]: Number format for a [`TOML`][`TOML-REF`] literal floating-point number. +//! - [`YAML`]: Number format for a [`YAML`][`YAML-REF`] literal floating-point number. +//! - [`XML`]: Number format for an [`XML`][`XML-REF`] literal floating-point number. +//! - [`SQLITE`]: Number format for a [`SQLite`] literal floating-point number. +//! - [`POSTGRESQL`]: Number format for a [`PostgreSQL`] literal floating-point number. +//! - [`MYSQL`]: Number format for a [`MySQL`] literal floating-point number. +//! - [`MONGODB`]: Number format for a [`MongoDB`] literal floating-point number. +//! +//! +#![cfg_attr( + feature = "format", + doc = " +[`Rust`]: https://www.rust-lang.org/ +[`Python`]: https://www.python.org/ +[`C++`]: https://en.cppreference.com/w/ +[`C`]: https://en.cppreference.com/w/c +[`Ruby`]: https://www.ruby-lang.org/en/ +[`Swift`]: https://developer.apple.com/swift/ +[`Golang`]: https://go.dev/ +[`Haskell`]: https://www.haskell.org/ +[`Javascript`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript +[`Perl`]: https://www.perl.org/ +[`PHP`]: https://www.php.net/ +[`Java`]: https://www.java.com/en/ +[`R`]: https://www.r-project.org/ +[`Kotlin`]: https://kotlinlang.org/ +[`Julia`]: https://julialang.org/ +[`C#`]: https://learn.microsoft.com/en-us/dotnet/csharp/ +[`Kawa`]: https://www.gnu.org/software/kawa/ +[`Gambit-C`]: https://gambitscheme.org/ +[`Guile`]: https://www.gnu.org/software/guile/ +[`Clojure`]: https://clojure.org/ +[`Erlang`]: https://www.erlang.org/ +[`Elm`]: https://elm-lang.org/ +[`Scala`]: https://www.scala-lang.org/ +[`Elixir`]: https://elixir-lang.org/ +[`FORTRAN`]: https://fortran-lang.org/ +[`D`]: https://dlang.org/ +[`Coffeescript`]: https://coffeescript.org/ +[`Cobol`]: https://www.ibm.com/think/topics/cobol +[`F#`]: https://fsharp.org/ +[`Visual Basic`]: https://learn.microsoft.com/en-us/dotnet/visual-basic/ +[`OCaml`]: https://ocaml.org/ +[`Objective-C`]: https://en.wikipedia.org/wiki/Objective-C +[`ReasonML`]: https://reasonml.github.io/ +[`Matlab`]: https://www.mathworks.com/products/matlab.html +[`Zig`]: https://ziglang.org/ +[`Sage`]: https://www.sagemath.org/ +[`JSON-REF`]: https://www.json.org/json-en.html +[`TOML-REF`]: https://toml.io/en/ +[`YAML-REF`]: https://yaml.org/ +[`XML-REF`]: https://en.wikipedia.org/wiki/XML +[`SQLite`]: https://www.sqlite.org/ +[`PostgreSQL`]: https://www.postgresql.org/ +[`MySQL`]: https://www.mysql.com/ +[`MongoDB`]: https://www.mongodb.com/ +" +)] use core::{mem, num}; @@ -943,7 +1090,6 @@ impl Options { /// This limits the total number of written digits, truncating based /// on the [`round_mode`] if more digits would normally be written. /// - /// /// # Panics /// /// This will panic when writing the float if the value is smaller than @@ -951,7 +1097,7 @@ impl Options { /// /// [`round_mode`]: Self::round_mode /// [`min_significant_digits`]: Self::min_significant_digits - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] #[inline(always)] pub fn set_max_significant_digits(&mut self, max_significant_digits: OptionUsize) { self.max_significant_digits = max_significant_digits; @@ -969,7 +1115,7 @@ impl Options { /// /// [`max_significant_digits`]: Self::max_significant_digits #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_min_significant_digits(&mut self, min_significant_digits: OptionUsize) { self.min_significant_digits = min_significant_digits; } @@ -980,7 +1126,7 @@ impl Options { /// (for base 10) will be writen in exponent notation, while any lower /// value will be written in decimal form. #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_positive_exponent_break(&mut self, positive_exponent_break: OptionI32) { self.positive_exponent_break = positive_exponent_break; } @@ -991,7 +1137,7 @@ impl Options { /// (for base 10) will be writen in exponent notation, while any larger /// value will be written in decimal form. #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_negative_exponent_break(&mut self, negative_exponent_break: OptionI32) { self.negative_exponent_break = negative_exponent_break; } @@ -1002,7 +1148,7 @@ impl Options { /// [`RoundMode::Round`] would produce `"1.2346"` while /// [`RoundMode::Truncate`] would produce `"1.2345"`. #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_round_mode(&mut self, round_mode: RoundMode) { self.round_mode = round_mode; } @@ -1015,7 +1161,7 @@ impl Options { /// /// [`min_significant_digits`]: Self::min_significant_digits #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_trim_floats(&mut self, trim_floats: bool) { self.trim_floats = trim_floats; } @@ -1027,7 +1173,7 @@ impl Options { /// Always safe, but may produce invalid output if the exponent /// is not a valid ASCII character. #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_exponent(&mut self, exponent: u8) { self.exponent = exponent; } @@ -1039,7 +1185,7 @@ impl Options { /// Always safe, but may produce invalid output if the decimal point /// is not a valid ASCII character. #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_decimal_point(&mut self, decimal_point: u8) { self.decimal_point = decimal_point; } @@ -1053,7 +1199,7 @@ impl Options { /// /// [`FORMATTED_SIZE`]: `lexical_util::constants::FormattedSize::FORMATTED_SIZE` #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_nan_string(&mut self, nan_string: Option<&'static [u8]>) { self.nan_string = nan_string; } @@ -1067,7 +1213,7 @@ impl Options { /// /// [`FORMATTED_SIZE`]: `lexical_util::constants::FormattedSize::FORMATTED_SIZE` #[inline(always)] - #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead."] + #[deprecated = "Options should be treated as immutable, use `OptionsBuilder` instead. Will be removed in 2.0."] pub fn set_inf_string(&mut self, inf_string: Option<&'static [u8]>) { self.inf_string = inf_string; } @@ -1173,503 +1319,564 @@ const fn unwrap_str(option: Option<&'static [u8]>) -> &'static [u8] { /// Standard number format. #[rustfmt::skip] pub const STANDARD: Options = Options::new(); -const_assert!(STANDARD.is_valid()); /// Numerical format with a decimal comma. +/// /// This is the standard numerical format for most of the world. #[rustfmt::skip] pub const DECIMAL_COMMA: Options = Options::builder() - .decimal_point(b',') - .build_unchecked(); -const_assert!(DECIMAL_COMMA.is_valid()); + .decimal_point(b',') + .build_strict(); /// Numerical format for hexadecimal floats, which use a `p` exponent. #[rustfmt::skip] pub const HEX_FLOAT: Options = Options::builder() - .exponent(b'p') - .build_unchecked(); -const_assert!(HEX_FLOAT.is_valid()); + .exponent(b'p') + .build_strict(); /// Numerical format where `^` is used as the exponent notation character. +/// /// This isn't very common, but is useful when `e` or `p` are valid digits. #[rustfmt::skip] pub const CARAT_EXPONENT: Options = Options::builder() - .exponent(b'^') - .build_unchecked(); -const_assert!(CARAT_EXPONENT.is_valid()); + .exponent(b'^') + .build_strict(); -/// Number format for a `Rust` literal floating-point number. +/// Number format for a [`Rust`] literal floating-point number. +/// +/// [`Rust`]: https://www.rust-lang.org/ #[rustfmt::skip] pub const RUST_LITERAL: Options = Options::builder() - .nan_string(options::RUST_LITERAL) - .inf_string(options::RUST_LITERAL) - .build_unchecked(); -const_assert!(RUST_LITERAL.is_valid()); + .nan_string(options::RUST_LITERAL) + .inf_string(options::RUST_LITERAL) + .build_strict(); -/// Number format for a `Python` literal floating-point number. +/// Number format for a [`Python`] literal floating-point number. +/// +/// [`Python`]: https://www.python.org/ #[rustfmt::skip] pub const PYTHON_LITERAL: Options = Options::builder() - .nan_string(options::PYTHON_LITERAL) - .inf_string(options::PYTHON_LITERAL) - .build_unchecked(); -const_assert!(PYTHON_LITERAL.is_valid()); + .nan_string(options::PYTHON_LITERAL) + .inf_string(options::PYTHON_LITERAL) + .build_strict(); -/// Number format for a `C++` literal floating-point number. +/// Number format for a [`C++`] literal floating-point number. +/// +/// [`C++`]: https://en.cppreference.com/w/ #[rustfmt::skip] pub const CXX_LITERAL: Options = Options::builder() - .nan_string(options::CXX_LITERAL_NAN) - .inf_string(options::CXX_LITERAL_INF) - .build_unchecked(); -const_assert!(CXX_LITERAL.is_valid()); + .nan_string(options::CXX_LITERAL_NAN) + .inf_string(options::CXX_LITERAL_INF) + .build_strict(); -/// Number format for a `C` literal floating-point number. +/// Number format for a [`C`] literal floating-point number. +/// +/// [`C`]: https://en.cppreference.com/w/c #[rustfmt::skip] pub const C_LITERAL: Options = Options::builder() - .nan_string(options::C_LITERAL_NAN) - .inf_string(options::C_LITERAL_INF) - .build_unchecked(); -const_assert!(CXX_LITERAL.is_valid()); + .nan_string(options::C_LITERAL_NAN) + .inf_string(options::C_LITERAL_INF) + .build_strict(); -/// Number format for a `Ruby` literal floating-point number. +/// Number format for a [`Ruby`] literal floating-point number. +/// +/// [`Ruby`]: https://www.ruby-lang.org/en/ #[rustfmt::skip] pub const RUBY_LITERAL: Options = Options::builder() - .positive_exponent_break(num::NonZeroI32::new(14)) - .negative_exponent_break(num::NonZeroI32::new(-4)) - .nan_string(options::RUBY_LITERAL_NAN) - .inf_string(options::RUBY_LITERAL_INF) - .build_unchecked(); -const_assert!(RUBY_LITERAL.is_valid()); + .positive_exponent_break(num::NonZeroI32::new(14)) + .negative_exponent_break(num::NonZeroI32::new(-4)) + .nan_string(options::RUBY_LITERAL_NAN) + .inf_string(options::RUBY_LITERAL_INF) + .build_strict(); -/// Number format to parse a `Ruby` float from string. +/// Number format to parse a [`Ruby`] float from string. +/// +/// [`Ruby`]: https://www.ruby-lang.org/en/ #[rustfmt::skip] pub const RUBY_STRING: Options = Options::builder() - .nan_string(options::RUBY_LITERAL_NAN) - .inf_string(options::RUBY_LITERAL_INF) - .build_unchecked(); -const_assert!(RUBY_STRING.is_valid()); + .nan_string(options::RUBY_LITERAL_NAN) + .inf_string(options::RUBY_LITERAL_INF) + .build_strict(); -/// Number format for a `Swift` literal floating-point number. +/// Number format for a [`Swift`] literal floating-point number. +/// +/// [`Swift`]: https://developer.apple.com/swift/ #[rustfmt::skip] pub const SWIFT_LITERAL: Options = Options::builder() - .nan_string(options::SWIFT_LITERAL) - .inf_string(options::SWIFT_LITERAL) - .build_unchecked(); -const_assert!(SWIFT_LITERAL.is_valid()); + .nan_string(options::SWIFT_LITERAL) + .inf_string(options::SWIFT_LITERAL) + .build_strict(); -/// Number format for a `Go` literal floating-point number. +/// Number format for a [`Golang`] literal floating-point number. +/// +/// [`Golang`]: https://go.dev/ #[rustfmt::skip] pub const GO_LITERAL: Options = Options::builder() - .nan_string(options::GO_LITERAL) - .inf_string(options::GO_LITERAL) - .build_unchecked(); -const_assert!(GO_LITERAL.is_valid()); + .nan_string(options::GO_LITERAL) + .inf_string(options::GO_LITERAL) + .build_strict(); -/// Number format for a `Haskell` literal floating-point number. +/// Number format for a [`Haskell`] literal floating-point number. +/// +/// [`Haskell`]: https://www.haskell.org/ #[rustfmt::skip] pub const HASKELL_LITERAL: Options = Options::builder() - .nan_string(options::HASKELL_LITERAL) - .inf_string(options::HASKELL_LITERAL) - .build_unchecked(); -const_assert!(HASKELL_LITERAL.is_valid()); + .nan_string(options::HASKELL_LITERAL) + .inf_string(options::HASKELL_LITERAL) + .build_strict(); -/// Number format to parse a `Haskell` float from string. +/// Number format to parse a [`Haskell`] float from string. +/// +/// [`Haskell`]: https://www.haskell.org/ #[rustfmt::skip] pub const HASKELL_STRING: Options = Options::builder() - .inf_string(options::HASKELL_STRING_INF) - .build_unchecked(); -const_assert!(HASKELL_STRING.is_valid()); + .inf_string(options::HASKELL_STRING_INF) + .build_strict(); -/// Number format for a `Javascript` literal floating-point number. +/// Number format for a [`Javascript`] literal floating-point number. +/// +/// [`Javascript`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript #[rustfmt::skip] pub const JAVASCRIPT_LITERAL: Options = Options::builder() - .inf_string(options::JAVASCRIPT_INF) - .build_unchecked(); -const_assert!(JAVASCRIPT_LITERAL.is_valid()); + .inf_string(options::JAVASCRIPT_INF) + .build_strict(); -/// Number format to parse a `Javascript` float from string. +/// Number format to parse a [`Javascript`] float from string. +/// +/// [`Javascript`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript #[rustfmt::skip] pub const JAVASCRIPT_STRING: Options = Options::builder() - .inf_string(options::JAVASCRIPT_INF) - .build_unchecked(); -const_assert!(JAVASCRIPT_STRING.is_valid()); + .inf_string(options::JAVASCRIPT_INF) + .build_strict(); -/// Number format for a `Perl` literal floating-point number. +/// Number format for a [`Perl`] literal floating-point number. +/// +/// [`Perl`]: https://www.perl.org/ #[rustfmt::skip] pub const PERL_LITERAL: Options = Options::builder() - .nan_string(options::PERL_LITERAL) - .inf_string(options::PERL_LITERAL) - .build_unchecked(); -const_assert!(PERL_LITERAL.is_valid()); + .nan_string(options::PERL_LITERAL) + .inf_string(options::PERL_LITERAL) + .build_strict(); -/// Number format for a `PHP` literal floating-point number. +/// Number format for a [`PHP`] literal floating-point number. +/// +/// [`PHP`]: https://www.php.net/ #[rustfmt::skip] pub const PHP_LITERAL: Options = Options::builder() - .nan_string(options::PHP_LITERAL_NAN) - .inf_string(options::PHP_LITERAL_INF) - .build_unchecked(); -const_assert!(PHP_LITERAL.is_valid()); + .nan_string(options::PHP_LITERAL_NAN) + .inf_string(options::PHP_LITERAL_INF) + .build_strict(); -/// Number format for a `Java` literal floating-point number. +/// Number format for a [`Java`] literal floating-point number. +/// +/// [`Java`]: https://www.java.com/en/ #[rustfmt::skip] pub const JAVA_LITERAL: Options = Options::builder() - .nan_string(options::JAVA_LITERAL) - .inf_string(options::JAVA_LITERAL) - .build_unchecked(); -const_assert!(JAVA_LITERAL.is_valid()); + .nan_string(options::JAVA_LITERAL) + .inf_string(options::JAVA_LITERAL) + .build_strict(); -/// Number format to parse a `Java` float from string. +/// Number format to parse a [`Java`] float from string. +/// +/// [`Java`]: https://www.java.com/en/ #[rustfmt::skip] pub const JAVA_STRING: Options = Options::builder() - .inf_string(options::JAVA_STRING_INF) - .build_unchecked(); -const_assert!(JAVA_STRING.is_valid()); + .inf_string(options::JAVA_STRING_INF) + .build_strict(); -/// Number format for an `R` literal floating-point number. +/// Number format for an [`R`] literal floating-point number. +/// +/// [`R`]: https://www.r-project.org/ #[rustfmt::skip] pub const R_LITERAL: Options = Options::builder() - .inf_string(options::R_LITERAL_INF) - .build_unchecked(); -const_assert!(R_LITERAL.is_valid()); + .inf_string(options::R_LITERAL_INF) + .build_strict(); -/// Number format for a `Kotlin` literal floating-point number. +/// Number format for a [`Kotlin`] literal floating-point number. +/// +/// [`Kotlin`]: https://kotlinlang.org/ #[rustfmt::skip] pub const KOTLIN_LITERAL: Options = Options::builder() - .nan_string(options::KOTLIN_LITERAL) - .inf_string(options::KOTLIN_LITERAL) - .build_unchecked(); -const_assert!(KOTLIN_LITERAL.is_valid()); + .nan_string(options::KOTLIN_LITERAL) + .inf_string(options::KOTLIN_LITERAL) + .build_strict(); -/// Number format to parse a `Kotlin` float from string. +/// Number format to parse a [`Kotlin`] float from string. +/// +/// [`Kotlin`]: https://kotlinlang.org/ #[rustfmt::skip] pub const KOTLIN_STRING: Options = Options::builder() - .inf_string(options::KOTLIN_STRING_INF) - .build_unchecked(); -const_assert!(KOTLIN_STRING.is_valid()); + .inf_string(options::KOTLIN_STRING_INF) + .build_strict(); -/// Number format for a `Julia` literal floating-point number. +/// Number format for a [`Julia`] literal floating-point number. +/// +/// [`Julia`]: https://julialang.org/ #[rustfmt::skip] pub const JULIA_LITERAL: Options = Options::builder() - .inf_string(options::JULIA_LITERAL_INF) - .build_unchecked(); -const_assert!(JULIA_LITERAL.is_valid()); + .inf_string(options::JULIA_LITERAL_INF) + .build_strict(); -/// Number format for a `C#` literal floating-point number. +/// Number format for a [`C#`] literal floating-point number. +/// +/// [`C#`]: https://learn.microsoft.com/en-us/dotnet/csharp/ #[rustfmt::skip] pub const CSHARP_LITERAL: Options = Options::builder() - .nan_string(options::CSHARP_LITERAL) - .inf_string(options::CSHARP_LITERAL) - .build_unchecked(); -const_assert!(CSHARP_LITERAL.is_valid()); + .nan_string(options::CSHARP_LITERAL) + .inf_string(options::CSHARP_LITERAL) + .build_strict(); -/// Number format to parse a `C#` float from string. +/// Number format to parse a [`C#`] float from string. +/// +/// [`C#`]: https://learn.microsoft.com/en-us/dotnet/csharp/ #[rustfmt::skip] pub const CSHARP_STRING: Options = Options::builder() - .inf_string(options::CSHARP_STRING_INF) - .build_unchecked(); -const_assert!(CSHARP_STRING.is_valid()); + .inf_string(options::CSHARP_STRING_INF) + .build_strict(); -/// Number format for a `Kawa` literal floating-point number. +/// Number format for a [`Kawa`] literal floating-point number. +/// +/// [`Kawa`]: https://www.gnu.org/software/kawa/ #[rustfmt::skip] pub const KAWA_LITERAL: Options = Options::builder() - .nan_string(options::KAWA) - .inf_string(options::KAWA) - .build_unchecked(); -const_assert!(KAWA_LITERAL.is_valid()); + .nan_string(options::KAWA) + .inf_string(options::KAWA) + .build_strict(); -/// Number format to parse a `Kawa` float from string. +/// Number format to parse a [`Kawa`] float from string. +/// +/// [`Kawa`]: https://www.gnu.org/software/kawa/ #[rustfmt::skip] pub const KAWA_STRING: Options = Options::builder() - .nan_string(options::KAWA) - .inf_string(options::KAWA) - .build_unchecked(); -const_assert!(KAWA_STRING.is_valid()); + .nan_string(options::KAWA) + .inf_string(options::KAWA) + .build_strict(); -/// Number format for a `Gambit-C` literal floating-point number. +/// Number format for a [`Gambit-C`] literal floating-point number. +/// +/// [`Gambit-C`]: https://gambitscheme.org/ #[rustfmt::skip] pub const GAMBITC_LITERAL: Options = Options::builder() - .nan_string(options::GAMBITC) - .inf_string(options::GAMBITC) - .build_unchecked(); -const_assert!(GAMBITC_LITERAL.is_valid()); + .nan_string(options::GAMBITC) + .inf_string(options::GAMBITC) + .build_strict(); -/// Number format to parse a `Gambit-C` float from string. +/// Number format to parse a [`Gambit-C`] float from string. +/// +/// [`Gambit-C`]: https://gambitscheme.org/ #[rustfmt::skip] pub const GAMBITC_STRING: Options = Options::builder() - .nan_string(options::GAMBITC) - .inf_string(options::GAMBITC) - .build_unchecked(); -const_assert!(GAMBITC_STRING.is_valid()); + .nan_string(options::GAMBITC) + .inf_string(options::GAMBITC) + .build_strict(); -/// Number format for a `Guile` literal floating-point number. +/// Number format for a [`Guile`] literal floating-point number. +/// +/// [`Guile`]: https://www.gnu.org/software/guile/ #[rustfmt::skip] pub const GUILE_LITERAL: Options = Options::builder() - .nan_string(options::GUILE) - .inf_string(options::GUILE) - .build_unchecked(); -const_assert!(GUILE_LITERAL.is_valid()); + .nan_string(options::GUILE) + .inf_string(options::GUILE) + .build_strict(); -/// Number format to parse a `Guile` float from string. +/// Number format to parse a [`Guile`] float from string. +/// +/// [`Guile`]: https://www.gnu.org/software/guile/ #[rustfmt::skip] pub const GUILE_STRING: Options = Options::builder() - .nan_string(options::GUILE) - .inf_string(options::GUILE) - .build_unchecked(); -const_assert!(GUILE_STRING.is_valid()); + .nan_string(options::GUILE) + .inf_string(options::GUILE) + .build_strict(); -/// Number format for a `Clojure` literal floating-point number. +/// Number format for a [`Clojure`] literal floating-point number. +/// +/// [`Clojure`]: https://clojure.org/ #[rustfmt::skip] pub const CLOJURE_LITERAL: Options = Options::builder() - .nan_string(options::CLOJURE_LITERAL) - .inf_string(options::CLOJURE_LITERAL) - .build_unchecked(); -const_assert!(CLOJURE_LITERAL.is_valid()); + .nan_string(options::CLOJURE_LITERAL) + .inf_string(options::CLOJURE_LITERAL) + .build_strict(); -/// Number format to parse a `Clojure` float from string. +/// Number format to parse a [`Clojure`] float from string. +/// +/// [`Clojure`]: https://clojure.org/ #[rustfmt::skip] pub const CLOJURE_STRING: Options = Options::builder() - .inf_string(options::CLOJURE_STRING_INF) - .build_unchecked(); -const_assert!(CLOJURE_STRING.is_valid()); + .inf_string(options::CLOJURE_STRING_INF) + .build_strict(); -/// Number format for an `Erlang` literal floating-point number. +/// Number format for an [`Erlang`] literal floating-point number. +/// +/// [`Erlang`]: https://www.erlang.org/ #[rustfmt::skip] pub const ERLANG_LITERAL: Options = Options::builder() - .nan_string(options::ERLANG_LITERAL_NAN) - .build_unchecked(); -const_assert!(ERLANG_LITERAL.is_valid()); + .nan_string(options::ERLANG_LITERAL_NAN) + .build_strict(); -/// Number format to parse an `Erlang` float from string. +/// Number format to parse an [`Erlang`] float from string. +/// +/// [`Erlang`]: https://www.erlang.org/ #[rustfmt::skip] pub const ERLANG_STRING: Options = Options::builder() - .nan_string(options::ERLANG_STRING) - .inf_string(options::ERLANG_STRING) - .build_unchecked(); -const_assert!(ERLANG_STRING.is_valid()); + .nan_string(options::ERLANG_STRING) + .inf_string(options::ERLANG_STRING) + .build_strict(); -/// Number format for an `Elm` literal floating-point number. +/// Number format for an [`Elm`] literal floating-point number. +/// +/// [`Elm`]: https://elm-lang.org/ #[rustfmt::skip] pub const ELM_LITERAL: Options = Options::builder() - .nan_string(options::ELM_LITERAL) - .inf_string(options::ELM_LITERAL) - .build_unchecked(); -const_assert!(ELM_LITERAL.is_valid()); + .nan_string(options::ELM_LITERAL) + .inf_string(options::ELM_LITERAL) + .build_strict(); -/// Number format to parse an `Elm` float from string. +/// Number format to parse an [`Elm`] float from string. +/// +/// [`Elm`]: https://elm-lang.org/ #[rustfmt::skip] pub const ELM_STRING: Options = Options::builder() - .nan_string(options::ELM_STRING_NAN) - .inf_string(options::ELM_STRING_INF) - .build_unchecked(); -const_assert!(ELM_STRING.is_valid()); + .nan_string(options::ELM_STRING_NAN) + .inf_string(options::ELM_STRING_INF) + .build_strict(); -/// Number format for a `Scala` literal floating-point number. +/// Number format for a [`Scala`] literal floating-point number. +/// +/// [`Scala`]: https://www.scala-lang.org/ #[rustfmt::skip] pub const SCALA_LITERAL: Options = Options::builder() - .nan_string(options::SCALA_LITERAL) - .inf_string(options::SCALA_LITERAL) - .build_unchecked(); -const_assert!(SCALA_LITERAL.is_valid()); + .nan_string(options::SCALA_LITERAL) + .inf_string(options::SCALA_LITERAL) + .build_strict(); -/// Number format to parse a `Scala` float from string. +/// Number format to parse a [`Scala`] float from string. +/// +/// [`Scala`]: https://www.scala-lang.org/ #[rustfmt::skip] pub const SCALA_STRING: Options = Options::builder() - .inf_string(options::SCALA_STRING_INF) - .build_unchecked(); -const_assert!(SCALA_STRING.is_valid()); + .inf_string(options::SCALA_STRING_INF) + .build_strict(); -/// Number format for an `Elixir` literal floating-point number. +/// Number format for an [`Elixir`] literal floating-point number. +/// +/// [`Elixir`]: https://elixir-lang.org/ #[rustfmt::skip] pub const ELIXIR_LITERAL: Options = Options::builder() - .nan_string(options::ELIXIR) - .inf_string(options::ELIXIR) - .build_unchecked(); -const_assert!(ELIXIR_LITERAL.is_valid()); + .nan_string(options::ELIXIR) + .inf_string(options::ELIXIR) + .build_strict(); -/// Number format to parse an `Elixir` float from string. +/// Number format to parse an [`Elixir`] float from string. +/// +/// [`Elixir`]: https://elixir-lang.org/ #[rustfmt::skip] pub const ELIXIR_STRING: Options = Options::builder() - .nan_string(options::ELIXIR) - .inf_string(options::ELIXIR) - .build_unchecked(); -const_assert!(ELIXIR_STRING.is_valid()); + .nan_string(options::ELIXIR) + .inf_string(options::ELIXIR) + .build_strict(); -/// Number format for a `FORTRAN` literal floating-point number. +/// Number format for a [`FORTRAN`] literal floating-point number. +/// +/// [`FORTRAN`]: https://fortran-lang.org/ #[rustfmt::skip] pub const FORTRAN_LITERAL: Options = Options::builder() - .nan_string(options::FORTRAN_LITERAL) - .inf_string(options::FORTRAN_LITERAL) - .build_unchecked(); -const_assert!(FORTRAN_LITERAL.is_valid()); + .nan_string(options::FORTRAN_LITERAL) + .inf_string(options::FORTRAN_LITERAL) + .build_strict(); -/// Number format for a `D` literal floating-point number. +/// Number format for a [`D`] literal floating-point number. +/// +/// [`D`]: https://dlang.org/ #[rustfmt::skip] pub const D_LITERAL: Options = Options::builder() - .nan_string(options::D_LITERAL) - .inf_string(options::D_LITERAL) - .build_unchecked(); -const_assert!(D_LITERAL.is_valid()); + .nan_string(options::D_LITERAL) + .inf_string(options::D_LITERAL) + .build_strict(); -/// Number format for a `Coffeescript` literal floating-point number. +/// Number format for a [`Coffeescript`] literal floating-point number. +/// +/// [`Coffeescript`]: https://coffeescript.org/ #[rustfmt::skip] pub const COFFEESCRIPT_LITERAL: Options = Options::builder() - .inf_string(options::COFFEESCRIPT_INF) - .build_unchecked(); -const_assert!(COFFEESCRIPT_LITERAL.is_valid()); + .inf_string(options::COFFEESCRIPT_INF) + .build_strict(); -/// Number format to parse a `Coffeescript` float from string. +/// Number format to parse a [`Coffeescript`] float from string. +/// +/// [`Coffeescript`]: https://coffeescript.org/ #[rustfmt::skip] pub const COFFEESCRIPT_STRING: Options = Options::builder() - .inf_string(options::COFFEESCRIPT_INF) - .build_unchecked(); -const_assert!(COFFEESCRIPT_STRING.is_valid()); + .inf_string(options::COFFEESCRIPT_INF) + .build_strict(); -/// Number format for a `COBOL` literal floating-point number. +/// Number format for a [`COBOL`] literal floating-point number. +/// +/// [`Cobol`]: https://www.ibm.com/think/topics/cobol #[rustfmt::skip] pub const COBOL_LITERAL: Options = Options::builder() - .nan_string(options::COBOL) - .inf_string(options::COBOL) - .build_unchecked(); -const_assert!(COBOL_LITERAL.is_valid()); + .nan_string(options::COBOL) + .inf_string(options::COBOL) + .build_strict(); -/// Number format to parse a `COBOL` float from string. +/// Number format to parse a [`COBOL`] float from string. +/// +/// [`Cobol`]: https://www.ibm.com/think/topics/cobol #[rustfmt::skip] pub const COBOL_STRING: Options = Options::builder() - .nan_string(options::COBOL) - .inf_string(options::COBOL) - .build_unchecked(); -const_assert!(COBOL_STRING.is_valid()); + .nan_string(options::COBOL) + .inf_string(options::COBOL) + .build_strict(); -/// Number format for an `F#` literal floating-point number. +/// Number format for an [`F#`] literal floating-point number. +/// +/// [`F#`]: https://fsharp.org/ #[rustfmt::skip] pub const FSHARP_LITERAL: Options = Options::builder() - .nan_string(options::FSHARP_LITERAL_NAN) - .inf_string(options::FSHARP_LITERAL_INF) - .build_unchecked(); -const_assert!(FSHARP_LITERAL.is_valid()); + .nan_string(options::FSHARP_LITERAL_NAN) + .inf_string(options::FSHARP_LITERAL_INF) + .build_strict(); -/// Number format for a `Visual Basic` literal floating-point number. +/// Number format for a [`Visual Basic`] literal floating-point number. +/// +/// [`Visual Basic`]: https://learn.microsoft.com/en-us/dotnet/visual-basic/ #[rustfmt::skip] pub const VB_LITERAL: Options = Options::builder() - .nan_string(options::VB_LITERAL) - .inf_string(options::VB_LITERAL) - .build_unchecked(); -const_assert!(VB_LITERAL.is_valid()); + .nan_string(options::VB_LITERAL) + .inf_string(options::VB_LITERAL) + .build_strict(); -/// Number format to parse a `Visual Basic` float from string. +/// Number format to parse a [`Visual Basic`] float from string. +/// +/// [`Visual Basic`]: https://learn.microsoft.com/en-us/dotnet/visual-basic/ #[rustfmt::skip] pub const VB_STRING: Options = Options::builder() - .inf_string(options::VB_STRING_INF) - .build_unchecked(); -const_assert!(VB_STRING.is_valid()); + .inf_string(options::VB_STRING_INF) + .build_strict(); -/// Number format for an `OCaml` literal floating-point number. +/// Number format for an [`OCaml`] literal floating-point number. +/// +/// [`OCaml`]: https://ocaml.org/ #[rustfmt::skip] pub const OCAML_LITERAL: Options = Options::builder() - .nan_string(options::OCAML_LITERAL_NAN) - .inf_string(options::OCAML_LITERAL_INF) - .build_unchecked(); -const_assert!(OCAML_LITERAL.is_valid()); + .nan_string(options::OCAML_LITERAL_NAN) + .inf_string(options::OCAML_LITERAL_INF) + .build_strict(); -/// Number format for an `Objective-C` literal floating-point number. +/// Number format for an [`Objective-C`] literal floating-point number. +/// +/// [`Objective-C`]: https://en.wikipedia.org/wiki/Objective-C #[rustfmt::skip] pub const OBJECTIVEC_LITERAL: Options = Options::builder() - .nan_string(options::OBJECTIVEC) - .inf_string(options::OBJECTIVEC) - .build_unchecked(); -const_assert!(OBJECTIVEC_LITERAL.is_valid()); + .nan_string(options::OBJECTIVEC) + .inf_string(options::OBJECTIVEC) + .build_strict(); -/// Number format to parse an `Objective-C` float from string. +/// Number format to parse an [`Objective-C`] float from string. +/// +/// [`Objective-C`]: https://en.wikipedia.org/wiki/Objective-C #[rustfmt::skip] pub const OBJECTIVEC_STRING: Options = Options::builder() - .nan_string(options::OBJECTIVEC) - .inf_string(options::OBJECTIVEC) - .build_unchecked(); -const_assert!(OBJECTIVEC_STRING.is_valid()); + .nan_string(options::OBJECTIVEC) + .inf_string(options::OBJECTIVEC) + .build_strict(); -/// Number format for an `ReasonML` literal floating-point number. +/// Number format for an [`ReasonML`] literal floating-point number. +/// +/// [`ReasonML`]: https://reasonml.github.io/ #[rustfmt::skip] pub const REASONML_LITERAL: Options = Options::builder() - .nan_string(options::REASONML_LITERAL_NAN) - .inf_string(options::REASONML_LITERAL_INF) - .build_unchecked(); -const_assert!(REASONML_LITERAL.is_valid()); + .nan_string(options::REASONML_LITERAL_NAN) + .inf_string(options::REASONML_LITERAL_INF) + .build_strict(); -/// Number format for a `MATLAB` literal floating-point number. +/// Number format for a [`MATLAB`] literal floating-point number. +/// +/// [`Matlab`]: https://www.mathworks.com/products/matlab.html #[rustfmt::skip] pub const MATLAB_LITERAL: Options = Options::builder() - .inf_string(options::MATLAB_LITERAL_INF) - .build_unchecked(); -const_assert!(MATLAB_LITERAL.is_valid()); + .inf_string(options::MATLAB_LITERAL_INF) + .build_strict(); -/// Number format for a `Zig` literal floating-point number. +/// Number format for a [`Zig`] literal floating-point number. +/// +/// [`Zig`]: https://ziglang.org/ #[rustfmt::skip] pub const ZIG_LITERAL: Options = Options::builder() - .nan_string(options::ZIG_LITERAL) - .inf_string(options::ZIG_LITERAL) - .build_unchecked(); -const_assert!(ZIG_LITERAL.is_valid()); + .nan_string(options::ZIG_LITERAL) + .inf_string(options::ZIG_LITERAL) + .build_strict(); -/// Number format for a `Safe` literal floating-point number. +/// Number format for a [`Sage`] literal floating-point number. +/// +/// [`Sage`]: https://www.sagemath.org/ #[rustfmt::skip] pub const SAGE_LITERAL: Options = Options::builder() - .inf_string(options::SAGE_LITERAL_INF) - .build_unchecked(); -const_assert!(SAGE_LITERAL.is_valid()); + .inf_string(options::SAGE_LITERAL_INF) + .build_strict(); -/// Number format for a `JSON` literal floating-point number. +/// Number format for a [`JSON`][`JSON-REF`] literal floating-point number. +/// +/// [`JSON-REF`]: https://www.json.org/json-en.html #[rustfmt::skip] pub const JSON: Options = Options::builder() - .nan_string(options::JSON) - .inf_string(options::JSON) - .build_unchecked(); -const_assert!(JSON.is_valid()); + .nan_string(options::JSON) + .inf_string(options::JSON) + .build_strict(); -/// Number format for a `TOML` literal floating-point number. +/// Number format for a [`TOML`][`TOML-REF`] literal floating-point number. +/// +/// [`TOML-REF`]: https://toml.io/en/ #[rustfmt::skip] pub const TOML: Options = Options::builder() - .nan_string(options::TOML) - .inf_string(options::TOML) - .build_unchecked(); -const_assert!(TOML.is_valid()); + .nan_string(options::TOML) + .inf_string(options::TOML) + .build_strict(); -/// Number format for a `YAML` literal floating-point number. +/// Number format for a [`YAML`][`YAML-REF`] literal floating-point number. +/// +/// [`YAML-REF`]: https://yaml.org/ #[rustfmt::skip] pub const YAML: Options = JSON; -/// Number format for an `XML` literal floating-point number. +/// Number format for an [`XML`][`XML-REF`] literal floating-point number. +/// +/// [`XML-REF`]: https://en.wikipedia.org/wiki/XML #[rustfmt::skip] pub const XML: Options = Options::builder() - .inf_string(options::XML_INF) - .build_unchecked(); -const_assert!(XML.is_valid()); + .inf_string(options::XML_INF) + .build_strict(); -/// Number format for a `SQLite` literal floating-point number. +/// Number format for a [`SQLite`] literal floating-point number. +/// +/// [`SQLite`]: https://www.sqlite.org/ #[rustfmt::skip] pub const SQLITE: Options = Options::builder() - .nan_string(options::SQLITE) - .inf_string(options::SQLITE) - .build_unchecked(); -const_assert!(SQLITE.is_valid()); + .nan_string(options::SQLITE) + .inf_string(options::SQLITE) + .build_strict(); -/// Number format for a `PostgreSQL` literal floating-point number. +/// Number format for a [`PostgreSQL`] literal floating-point number. +/// +/// [`PostgreSQL`]: https://www.postgresql.org/ #[rustfmt::skip] pub const POSTGRESQL: Options = Options::builder() - .nan_string(options::POSTGRESQL) - .inf_string(options::POSTGRESQL) - .build_unchecked(); -const_assert!(POSTGRESQL.is_valid()); + .nan_string(options::POSTGRESQL) + .inf_string(options::POSTGRESQL) + .build_strict(); -/// Number format for a `MySQL` literal floating-point number. +/// Number format for a [`MySQL`] literal floating-point number. +/// +/// [`MySQL`]: https://www.mysql.com/ #[rustfmt::skip] pub const MYSQL: Options = Options::builder() - .nan_string(options::MYSQL) - .inf_string(options::MYSQL) - .build_unchecked(); -const_assert!(MYSQL.is_valid()); + .nan_string(options::MYSQL) + .inf_string(options::MYSQL) + .build_strict(); -/// Number format for a `MongoDB` literal floating-point number. +/// Number format for a [`MongoDB`] literal floating-point number. +/// +/// [`MongoDB`]: https://www.mongodb.com/ #[rustfmt::skip] pub const MONGODB: Options = Options::builder() - .inf_string(options::MONGODB_INF) - .build_unchecked(); -const_assert!(MONGODB.is_valid()); + .inf_string(options::MONGODB_INF) + .build_strict(); diff --git a/lexical-write-integer/src/lib.rs b/lexical-write-integer/src/lib.rs index 9c44223f..8cbf41ab 100644 --- a/lexical-write-integer/src/lib.rs +++ b/lexical-write-integer/src/lib.rs @@ -27,22 +27,7 @@ //! //! Using [`FormattedSize::FORMATTED_SIZE_DECIMAL`] guarantees the buffer //! will be large enough to write the digits for all numbers of that -//! type. In addition, `digits` is guaranteed to start at the same -//! address as `buffer`, that is: -//! -//! ```rust -//! # use core::str; -//! use lexical_write_integer::{FormattedSize, ToLexical}; -//! -//! let mut buffer = [0u8; u64::FORMATTED_SIZE_DECIMAL]; -//! let digits = 1234u64.to_lexical(&mut buffer); -//! assert_eq!(str::from_utf8(digits), Ok("1234")); -//! -//! // NOTE: This is done for demonstration: don't use this in real code. -//! let digits_ptr = digits.as_ptr(); -//! let buffer_ptr = buffer.as_ptr(); -//! assert_eq!(digits_ptr, buffer_ptr); -//! ``` +//! type. //! //! # Features //!