-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update to [email protected] and remove re-export of ion-rs types #220
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.
🚀
_ => None, | ||
} | ||
} | ||
fn as_u64(&self) -> Option<u64> { | ||
match self.value() { | ||
Value::Int(Int::I64(i)) => i.to_u64(), | ||
Value::Int(Int::BigInt(i)) => i.to_u64(), | ||
Value::Int(i) => i.as_i128()?.to_u64(), |
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.
...but weirdly, there's not an Int::as_u64()
method.
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.
Tracking this as amazon-ion/ion-rust#840.
|
||
// write the previously constructed ISL model into a schema file using `write_to` | ||
let write_schema_result = expected_schema.write_to(&mut writer); | ||
let write_schema_result = expected_schema.write_as_ion(&mut writer); |
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.
This works, though it can also be written writer.write(expected_schema)
.
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.
It can't be written that way because IslSchema
does not implement WriteAsIon
. This is because WriteAsIon
implementations are allowed to write a single value, but an IslSchema
is a sequence of top-level values.
Ok(()) | ||
} | ||
Limit::Inclusive(value) if self.lower == self.upper => value.fmt(f), | ||
_ => f.write_fmt(format_args!("range::[{},{}]", self.lower, self.upper)), |
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.
This is my first time seeing a manual invocation of format_args!
in the wild. 🤔
@@ -131,7 +131,7 @@ impl BuiltInTypeDefinition { | |||
let mut constraints = vec![]; | |||
|
|||
// parses an isl_type to a TypeDefinition | |||
let type_name = isl_type.name(); | |||
let type_name = isl_type.name().map(|x| x.to_owned()); |
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.
TIL that Option<&str>
doesn't implement ToOwned
.
Issue #, if available:
#137
Description of changes:
[email protected]
WriteToIsl
, so I removed theWriteToIsl
trait in favor of implementingWriteAsIon
ion-schema-tests
to the latest commit. (Required becauseion-rs
supports only up to u128 for integers.)ranges.rs
to useMin
andMax
instead ofUnbounded
. That made it cleaner to implementWriteAsIon
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.