Skip to content

Consider Using ZeroTrie, Option Types in Units Conversion Provider and removing dimensions #4313

Open
@younies

Description

@younies

In the experimental/unitsconversion/src/provider.rs file, there are a couple of potential improvements that could be made to enhance the code quality and maintainability.

  1. Consider using ZeroTrie: Currently, we are using ZeroMap to map from unit name to indices.
/// Maps from unit name (e.g. foot) to the index of the unit in the `unit_quantity` vector.
#[cfg_attr(feature = "serde", serde(borrow))]
pub units_info: ZeroMap<'data, str, UnitsInfoIndex>;
  1. Consider using Option<Dimension> and Option<ConversionInfo>: Currently, we are using indices to reference the Dimension and ConversionInfo in their respective vectors.
  2. Consider removing the dimension from the units conversion data. During the units conversion, not all the users wants to know the dimension. For example: acre's dimension is area

Metadata

Metadata

Assignees

Labels

C-numbersComponent: Numbers, units, currencies

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions