Skip to content

[ion-c-sys] Generic Associated Traits for Reader Writer Traits #98

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

Closed
almann opened this issue Sep 1, 2020 · 0 comments
Closed

[ion-c-sys] Generic Associated Traits for Reader Writer Traits #98

almann opened this issue Sep 1, 2020 · 0 comments
Labels
enhancement New feature or request ion-c-sys Issues related to Ion C bindings

Comments

@almann
Copy link
Contributor

almann commented Sep 1, 2020

This is generally applicable to ion-rs as well, but as we design the traits we want to have for our APIs, we should be consider how Generic Associated Traits (GAT) can be used to make our APIs reasonably flexible while maintaining static polymorphism.

Currently, delegation via our current APIs are difficult because we cannot have an associated type that can be constructed with a per invocation lifetime. This example illustrates this, and shows how we can work around this by the judicious use of unsafe code, by essentially emulating the reference with pointers we know to be scoped appropriately. We also work around the lack of GAT by simplifying the value writer used in the implementation of IonCAnnotationsFieldWriter for IonCWriterHandle by refering to Self which works, but makes the API potentially easier to misuse.

@almann almann added enhancement New feature or request ion-c-sys Issues related to Ion C bindings labels Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ion-c-sys Issues related to Ion C bindings
Projects
None yet
Development

No branches or pull requests

2 participants