Skip to content
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

Clean up IonSchemaError and IonSchemaResult constructor functions #196

Open
popematt opened this issue Jul 3, 2023 · 0 comments
Open

Clean up IonSchemaError and IonSchemaResult constructor functions #196

popematt opened this issue Jul 3, 2023 · 0 comments

Comments

@popematt
Copy link
Contributor

popematt commented Jul 3, 2023

ion-schema-rust should implement a similar approach as what is described here:

🗺️ IonFailure (imported above on line 5) is a new crate-visible trait that provides extension methods for the IonResult and IonError types.

Previously, each IonError variant had one helper function in crate::result that would build an IonResult, and an accompanying function that would being an IonError. The names got pretty weird. For example, decoding_error would return an IonResult (not an error, as one could reasonably infer), and decoding_error_raw would return an IonError. (The "raw" indicated that it hadn't gone through the final step of wrapping the IonError in a Result::Err, which was not an obvious connection.)

The IonFailure trait replaces those method pairs. Now you can use IonResult::decoding_error to make an IonResult and you can use IonError::decoding_error to make an IonError. Much more straightforward.

Originally posted by @zslayton in amazon-ion/ion-rust#584 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant