-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More from_str
cleanups
#5182
base: main
Are you sure you want to change the base?
More from_str
cleanups
#5182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're removing impls from TinyStr wrapper types and instead using direct construction, which seems like a positive change since it avoids an unwrap, despite being more verbose.
|
||
impl FromStr for PluralOperands { | ||
#[cfg(feature = "datagen")] | ||
impl core::str::FromStr for PluralOperands { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion: I'm not sure we want impl FromStr for PluralOperands
to be cfg(datagen)
, although I'm fine if we do since we have a way to get this same functionality via fixed_decimal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can create plural operands from all numeric types as well as fixed decimal, infallibly.
ffi/ecma402/src/pluralrules.rs
Outdated
dbg!("ret={:?}\n---\n", &ret); | ||
ret | ||
let _nstr = fixed_format(n, &opts); | ||
todo!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you want me to do here? I'm tempted to just remove the whole crate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think endeavor to keep it working. It's not that much code to keep working.
In this case, just change PluralOperands::from_str
to FixedDecimal::from_str
.
ffi/ecma402/src/pluralrules.rs
Outdated
dbg!("ret={:?}\n---\n", &ret); | ||
ret | ||
let _nstr = fixed_format(n, &opts); | ||
todo!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think endeavor to keep it working. It's not that much code to keep working.
In this case, just change PluralOperands::from_str
to FixedDecimal::from_str
.
#[test] | ||
fn format_conversion() { | ||
#[derive(Debug)] | ||
struct TestCase { | ||
n: f64, | ||
opts: Options, | ||
expected: PluralOperands, | ||
} | ||
let tests = [TestCase { | ||
n: 1.5, | ||
opts: Options { | ||
in_type: Type::Cardinal, | ||
minimum_integer_digits: 3, | ||
minimum_fraction_digits: 2, | ||
maximum_fraction_digits: 3, | ||
minimum_significant_digits: 3, | ||
maximum_significant_digits: 4, | ||
}, | ||
expected: RawPluralOperands { | ||
i: 1, | ||
v: 2, | ||
w: 1, | ||
f: 50, | ||
t: 5, | ||
c: 0, | ||
} | ||
.into(), | ||
}]; | ||
for test in tests { | ||
let actual = to_icu4x_operands(test.n, test.opts.clone()); | ||
assert_eq!(test.expected, actual, "test: {:?}", &test); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please restore the test for to_icu4x_operands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm it's broken
#4931