Skip to content

Commit 85059f6

Browse files
committed
Remove supports_parsing_* and supports_writing_*.
This is a waste of flag space and should be removed prior to any releases.
1 parent 6cf2cba commit 85059f6

File tree

15 files changed

+54
-525
lines changed

15 files changed

+54
-525
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Re-export `NumberFormat` to our other crates (#204).
1818
- Added `Options::from_radix` for all options for similar APIs for each (#208).
1919
- Support for `required_integer_digits_with_exponent`, `required_fraction_digits_with_exponent`, and `required_mantissa_digits_with_exponent`, that is,`1.e5` and `.1e5`, as opposed to just requiring`1e5` (#215).
20-
- Added `supports_parsing_integers`, `supports_parsing_floats`, `supports_writing_integers`, and `supports_writing_floats` for our number formats (#215).
2120
- Added `required_base_prefix` and `required_base_suffix` for our number formats, requiring base prefixes and/or suffixes when parsing, and allowing writing base prefixes and/or suffixes (#215).
2221
- Added `NumberFormatBuilder::none()` for create a format with no flags set (#215).
2322
- Added in many more digit separator flags for the `NumberFormat`, including for signs, base prefixes, base suffixes, and restricting digit separators at the start of the number (#215).
23+
- Added many more pre-defined formatting constants (#215).
2424

2525
### Changed
2626

lexical-parse-float/src/api.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ macro_rules! float_from_lexical {
5151
) -> lexical_util::result::Result<Self>
5252
{
5353
let format = NumberFormat::<{ FORMAT }> {};
54-
if !format.supports_parsing_floats() {
55-
return Err(Error::Unsupported);
56-
} else if !format.is_valid() {
54+
if !format.is_valid() {
5755
return Err(format.error());
5856
} else if !is_valid_options_punctuation(FORMAT, options.exponent(), options.decimal_point()) {
5957
return Err(Error::InvalidPunctuation);
@@ -68,9 +66,7 @@ macro_rules! float_from_lexical {
6866
) -> lexical_util::result::Result<(Self, usize)>
6967
{
7068
let format = NumberFormat::<{ FORMAT }> {};
71-
if !format.supports_parsing_floats() {
72-
return Err(Error::Unsupported);
73-
} else if !format.is_valid() {
69+
if !format.is_valid() {
7470
return Err(format.error());
7571
} else if !is_valid_options_punctuation(FORMAT, options.exponent(), options.decimal_point()) {
7672
return Err(Error::InvalidPunctuation);

lexical-parse-float/tests/api_tests.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,38 +1276,6 @@ fn issue68_test() {
12761276
assert_eq!(f64::INFINITY, f64::from_lexical_with_options::<FORMAT>(hex, &OPTIONS).unwrap());
12771277
}
12781278

1279-
#[test]
1280-
#[cfg(feature = "format")]
1281-
fn unsupported_test() {
1282-
const FORMAT: u128 = NumberFormatBuilder::new().supports_parsing_floats(false).build_strict();
1283-
const OPTIONS: Options = Options::new();
1284-
1285-
let float = "12345.0";
1286-
let value = f64::from_lexical_with_options::<FORMAT>(float.as_bytes(), &OPTIONS);
1287-
assert_eq!(value, Err(Error::Unsupported));
1288-
1289-
let value = f64::from_lexical_partial_with_options::<FORMAT>(float.as_bytes(), &OPTIONS);
1290-
assert_eq!(value, Err(Error::Unsupported));
1291-
}
1292-
1293-
#[test]
1294-
#[cfg(feature = "format")]
1295-
fn supported_test() {
1296-
const FORMAT: u128 = NumberFormatBuilder::new()
1297-
.supports_parsing_integers(false)
1298-
.supports_writing_integers(false)
1299-
.supports_writing_floats(false)
1300-
.build_strict();
1301-
const OPTIONS: Options = Options::new();
1302-
1303-
let float = "12345.0";
1304-
let value = f64::from_lexical_with_options::<FORMAT>(float.as_bytes(), &OPTIONS);
1305-
assert_eq!(value, Ok(12345.0));
1306-
1307-
let value = f64::from_lexical_partial_with_options::<FORMAT>(float.as_bytes(), &OPTIONS);
1308-
assert_eq!(value, Ok((12345.0, 7)));
1309-
}
1310-
13111279
#[test]
13121280
#[cfg(all(feature = "format", feature = "power-of-two"))]
13131281
fn require_base_prefix_test() {

lexical-parse-integer/src/api.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#![doc(hidden)]
44

5-
use lexical_util::error::Error;
65
use lexical_util::format::{NumberFormat, STANDARD};
76
use lexical_util::{from_lexical, from_lexical_with_options};
87

@@ -43,9 +42,7 @@ macro_rules! integer_from_lexical {
4342
) -> lexical_util::result::Result<Self>
4443
{
4544
let format = NumberFormat::<{ FORMAT }> {};
46-
if !format.supports_parsing_integers() {
47-
return Err(Error::Unsupported);
48-
} else if !format.is_valid() {
45+
if !format.is_valid() {
4946
return Err(format.error());
5047
}
5148
Self::parse_complete::<FORMAT>(bytes, options)
@@ -58,9 +55,7 @@ macro_rules! integer_from_lexical {
5855
) -> lexical_util::result::Result<(Self, usize)>
5956
{
6057
let format = NumberFormat::<{ FORMAT }> {};
61-
if !format.supports_parsing_integers() {
62-
return Err(Error::Unsupported);
63-
} else if !format.is_valid() {
58+
if !format.is_valid() {
6459
return Err(format.error());
6560
}
6661
Self::parse_partial::<FORMAT>(bytes, options)

lexical-parse-integer/tests/api_tests.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -367,50 +367,6 @@ fn base_prefix_and_suffix_test() {
367367
assert_eq!(i32::from_lexical_with_options::<FORMAT>(b"+0x", &OPTIONS), Err(Error::Empty(3)));
368368
}
369369

370-
#[test]
371-
#[cfg(feature = "format")]
372-
fn unsupported_test() {
373-
const FORMAT: u128 = NumberFormatBuilder::new().supports_parsing_integers(false).build_strict();
374-
const OPTIONS: Options = Options::new();
375-
376-
let integer = "12345";
377-
let value = i64::from_lexical_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
378-
assert_eq!(value, Err(Error::Unsupported));
379-
380-
let value = i64::from_lexical_partial_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
381-
assert_eq!(value, Err(Error::Unsupported));
382-
383-
let value = u64::from_lexical_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
384-
assert_eq!(value, Err(Error::Unsupported));
385-
386-
let value = u64::from_lexical_partial_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
387-
assert_eq!(value, Err(Error::Unsupported));
388-
}
389-
390-
#[test]
391-
#[cfg(feature = "format")]
392-
fn supported_test() {
393-
const FORMAT: u128 = NumberFormatBuilder::new()
394-
.supports_parsing_floats(false)
395-
.supports_writing_integers(false)
396-
.supports_writing_floats(false)
397-
.build_strict();
398-
const OPTIONS: Options = Options::new();
399-
400-
let integer = "12345";
401-
let value = i64::from_lexical_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
402-
assert_eq!(value, Ok(12345));
403-
404-
let value = i64::from_lexical_partial_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
405-
assert_eq!(value, Ok((12345, 5)));
406-
407-
let value = u64::from_lexical_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
408-
assert_eq!(value, Ok(12345));
409-
410-
let value = u64::from_lexical_partial_with_options::<FORMAT>(integer.as_bytes(), &OPTIONS);
411-
assert_eq!(value, Ok((12345, 5)));
412-
}
413-
414370
#[test]
415371
#[cfg(all(feature = "format", feature = "power-of-two"))]
416372
fn require_base_prefix_test() {

lexical-util/src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ pub enum Error {
9898
InvalidConsecutiveExponentDigitSeparator,
9999
/// Invalid flags were set without the format feature.
100100
InvalidFlags,
101-
/// If the operation is unsupported.
102-
Unsupported,
103101

104102
// OPTION ERRORS
105103
/// Invalid NaN string: must start with an `n` character.
@@ -195,7 +193,6 @@ impl Error {
195193
Self::InvalidConsecutiveFractionDigitSeparator => "'enabled consecutive digit separators in the fraction without setting a valid location'",
196194
Self::InvalidConsecutiveExponentDigitSeparator => "'enabled consecutive digit separators in the exponent without setting a valid location'",
197195
Self::InvalidFlags => "'invalid flags enabled without the format feature'",
198-
Self::Unsupported => "'the desired operation is unsupported for this format'",
199196

200197
// OPTION ERRORS
201198
Self::InvalidNanString => "'NaN string must started with `n`'",
@@ -264,7 +261,6 @@ impl Error {
264261
Self::InvalidConsecutiveFractionDigitSeparator => None,
265262
Self::InvalidConsecutiveExponentDigitSeparator => None,
266263
Self::InvalidFlags => None,
267-
Self::Unsupported => None,
268264

269265
// OPTION ERRORS
270266
Self::InvalidNanString => None,
@@ -332,7 +328,6 @@ impl Error {
332328
InvalidConsecutiveExponentDigitSeparator
333329
);
334330
is_error_type!(is_invalid_flags, InvalidFlags);
335-
is_error_type!(is_unsupported, Unsupported);
336331
is_error_type!(is_invalid_nan_string, InvalidNanString);
337332
is_error_type!(is_nan_string_too_long, NanStringTooLong);
338333
is_error_type!(is_invalid_inf_string, InvalidInfString);
@@ -435,7 +430,6 @@ impl fmt::Display for Error {
435430
format_message!(formatter, description)
436431
},
437432
Self::InvalidFlags => format_message!(formatter, description),
438-
Self::Unsupported => format_message!(formatter, description),
439433

440434
// OPTION ERRORS
441435
Self::InvalidNanString => options_message!(formatter, description),

lexical-util/src/feature_format.rs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -755,78 +755,6 @@ impl<const FORMAT: u128> NumberFormat<FORMAT> {
755755
Self::REQUIRED_MANTISSA_DIGITS_WITH_EXPONENT
756756
}
757757

758-
/// If the format supports parsing integers.
759-
///
760-
/// See [`supports_parsing_integers`][Self::supports_parsing_integers].
761-
pub const SUPPORTS_PARSING_INTEGERS: bool = from_flag!(FORMAT, SUPPORTS_PARSING_INTEGERS);
762-
763-
/// Get if the format supports parsing integers.
764-
///
765-
/// Can only be modified with [`feature`][crate#features] `format`. Defaults
766-
/// to [`true`].
767-
///
768-
/// # Used For
769-
///
770-
/// - Parse Integer
771-
#[inline(always)]
772-
pub const fn supports_parsing_integers(&self) -> bool {
773-
Self::SUPPORTS_PARSING_INTEGERS
774-
}
775-
776-
/// If the format supports parsing floats.
777-
///
778-
/// See [`supports_parsing_floats`][Self::supports_parsing_floats].
779-
pub const SUPPORTS_PARSING_FLOATS: bool = from_flag!(FORMAT, SUPPORTS_PARSING_FLOATS);
780-
781-
/// Get if the format supports parsing floats.
782-
///
783-
/// Can only be modified with [`feature`][crate#features] `format`. Defaults
784-
/// to [`true`].
785-
///
786-
/// # Used For
787-
///
788-
/// - Parse Float
789-
#[inline(always)]
790-
pub const fn supports_parsing_floats(&self) -> bool {
791-
Self::SUPPORTS_PARSING_FLOATS
792-
}
793-
794-
/// If the format supports writing integers.
795-
///
796-
/// See [`supports_writing_integers`][Self::supports_writing_integers].
797-
pub const SUPPORTS_WRITING_INTEGERS: bool = from_flag!(FORMAT, SUPPORTS_WRITING_INTEGERS);
798-
799-
/// Get if the format supports writing integers.
800-
///
801-
/// Can only be modified with [`feature`][crate#features] `format`. Defaults
802-
/// to [`true`].
803-
///
804-
/// # Used For
805-
///
806-
/// - Write Integer
807-
#[inline(always)]
808-
pub const fn supports_writing_integers(&self) -> bool {
809-
Self::SUPPORTS_WRITING_INTEGERS
810-
}
811-
812-
/// If the format supports writing floats.
813-
///
814-
/// See [`supports_writing_floats`][Self::supports_writing_floats].
815-
pub const SUPPORTS_WRITING_FLOATS: bool = from_flag!(FORMAT, SUPPORTS_WRITING_FLOATS);
816-
817-
/// Get if the format supports writing floats.
818-
///
819-
/// Can only be modified with [`feature`][crate#features] `format`. Defaults
820-
/// to [`true`].
821-
///
822-
/// # Used For
823-
///
824-
/// - Write Float
825-
#[inline(always)]
826-
pub const fn supports_writing_floats(&self) -> bool {
827-
Self::SUPPORTS_WRITING_FLOATS
828-
}
829-
830758
/// If the format requires base prefixes.
831759
///
832760
/// See [`required_base_prefix`][Self::required_base_prefix].

0 commit comments

Comments
 (0)