time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.09k stars 273 forks source link

Add getters for ComponentRange #565

Closed a1ien closed 1 year ago

a1ien commented 1 year ago

This methods is useful if you want to implement custom error printing.

codecov[bot] commented 1 year ago

Codecov Report

Merging #565 (0183065) into main (aab760f) will decrease coverage by 0.1%. The diff coverage is 0.0%.

@@           Coverage Diff           @@
##            main    #565     +/-   ##
=======================================
- Coverage   95.7%   95.6%   -0.1%     
=======================================
  Files         78      78             
  Lines       8703    8711      +8     
=======================================
- Hits        8330    8329      -1     
- Misses       373     382      +9     
Impacted Files Coverage Δ
time/src/error/component_range.rs 79.5% <0.0%> (-20.5%) :arrow_down:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

jhpratt commented 1 year ago

This is deliberately private, as I do not want to guarantee the type being stored.

a1ien commented 1 year ago

Suggest then how to customize the error message. How to get what range is incorrect? For example, in the current display implementation, you print the range as 1..=30, but this does not look good for the user interface.

jhpratt commented 1 year ago

Currently, you cannot obtain the range of validity, at least easily. I suppose you could work from the component name and whether it's conditional to determine the name, but that's about it.