Alexhuszagh/rust-lexical

[FEATURE] Refactor available features

Alexhuszagh opened this issue · 2 comments

Problem

It is currently impossible to do a lot of things, without private forks of lexical-core.

  1. Cannot have optionally-trimmed floats (IE, "12.0" and "12").
  2. Cannot use correct (slow) and incorrect (fast) parsers at the same time.
  3. Heavy reliance on global state (#45).

There are also numerous features that are rarely used (including some undocumented ones), and have dubious utility:

  1. table (should be the default, since correct depends on it).
  2. unchecked_index (introduces security risks if enabled, and has no tangible performance benefits).
  3. libm (should be enabled by default, see #61).
  4. noinline (debugging tools, no longer used).
  5. format (should be enabled by default, with fast-path algorithms to avoid overhead).

Currently, this is fully implemented as of 40c59a3#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542.

The features removed are:

  1. table
  2. unchecked_index
  3. libm
  4. noinline

The added features are:

  1. no_alloc (enabled by default, avoid using a system allocator except when radix is enabled).

We've also broken the crate into submodules, which are featured-gated:

  1. parse_floats (enabled the float parser).
  2. parse_integers (enabled the integer parser).
  3. write_floats (enabled the float writer).
  4. write_integers (enabled the integer writer).

The new submodules should lead to faster compile times when features are disabled.

I will be keeping this issue until the v0.8 version is published.