Expand description
Shared utilities for lexical conversion routines.
These are not meant to be used publicly for any numeric conversion routines, but provide optimized math routines, format packed struct definitions, and custom iterators for all workspaces.
§Features
power-of-two
- Add support for parsing and writing power-of-two integer strings.radix
- Add support for parsing and writing strings of any radix.format
- Add support for custom number formats.write-integers
- Add support for writing integers (used forlexical-write-integer
).write-floats
- Add support for writing floats (used forlexical-write-float
).parse-integers
- Add support for parsing integers (used forlexical-parse-integer
).parse-floats
- Add support for parsing floats (used forlexical-write-float
).compact
- Reduce code size at the cost of performance.f16
- Enable support for half-precisionf16
andbf16
floats.std
(Default) - Disable to allow use in ano_std
environment.
§Public API
lexical-util
mainly exists as an implementation detail for
the other lexical crates, although its API is mostly stable. If you would
like to use a high-level API that writes to and parses from String
and
str
, respectively, please look at lexical
instead. If you would like
an API that supports multiple numeric conversions without a dependency on
alloc
, please look at lexical-core
instead.
Any undocumented, implementation details may change release-to-release
without major or minor version changes. Use internal implementation details
at your own risk. Any changes other than to NumberFormatBuilder
,
NumberFormat
, format
, and options
will not be considered
a breaking change.
§Version Support
The minimum, standard, required version is 1.63.0
, for
const generic support. Older versions of lexical support older Rust
versions.
§Safety Guarantees
For a detailed breakdown on the use of unsafe
, how and why our traits
are implemented safely, and how to verify this, see Safety
.
Re-exports§
pub use format::NumberFormat;
pub use format::NumberFormatBuilder;
pub use options::ParseOptions;
parse-floats
orparse-integers
pub use options::WriteOptions;
write-floats
orwrite-integers
pub use result::Result;
Modules§
- algorithm
- Simple, shared algorithms for slices and iterators.
- ascii
- Utilities for working with ASCII characters.
- bf16
f16
- Brain Floating Point implementation, a 16-bit type used in machine learning.
- digit
- Utilities to process digits.
- div128
Non- compact
and (write-floats
orwrite-integers
) - Optimized division algorithms for u128.
- extended_
float parse-floats
orwrite-floats
- Extended precision floating-point type.
- f16
f16
- Half-precision IEEE-754 floating point implementation.
- format
- The creation and processing of number format packed structs.
- iterator
parse-floats
orparse-integers
- Specialized iterator traits.
- mul
- Fast multiplication routines.
- num
- Utilities for Rust numbers.
- options
- Shared traits for the options API.
- result
- Result type for numeric parsing functions.
- step
parse-floats
orparse-integers
orwrite-floats
orwrite-integers
- The maximum digits that can be held in a u64 for a given radix without overflowing.
Macros§
- from_
lexical parse-floats
orparse-integers
- Define the
FromLexical
trait. - from_
lexical_ with_ options parse-floats
orparse-integers
- Define the
FromLexicalWithOptions
trait. - to_
lexical write-floats
orwrite-integers
- Define the
ToLexical
trait. - to_
lexical_ with_ options write-floats
orwrite-integers
- Define the
ToLexicalWithOptions
trait.
Enums§
- Error
- Error code during parsing, indicating failure type.
Constants§
- BUFFER_
SIZE write-floats
orwrite-integers
- Maximum number of bytes required to serialize any number with default options to string.
Traits§
- Formatted
Size write-floats
orwrite-integers
- The size, in bytes, of formatted values.