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

returning owned data from SpanContents::data #410

Open
The-Minecraft-Scientist opened this issue Nov 22, 2024 · 2 comments
Open

returning owned data from SpanContents::data #410

The-Minecraft-Scientist opened this issue Nov 22, 2024 · 2 comments

Comments

@The-Minecraft-Scientist
Copy link

The-Minecraft-Scientist commented Nov 22, 2024

I have a scenario where source bytes for my custom SpanContents are potentially dynamically generated by each call to read_span on my source code, returning an Arc<str> (which is then stored in my SpanContents), and it would be very helpful to be able to return an opaque, possibly-owned value instead of &'a [u8] (something along the lines of impl AsRef<[u8]> + 'a)
edit 1 : impl AsRef<[u8]> + 'a breaks object safety (duh), looking for an alternative

@The-Minecraft-Scientist
Copy link
Author

The-Minecraft-Scientist commented Nov 22, 2024

I realized after the fact that I can simply impl<'a> SpanContents<'a> for &'a MyOwnedSpanContents, which solves most of my issues.
edit: it didn't

@The-Minecraft-Scientist
Copy link
Author

Reopening because that impl that "solved things" only pushed the issues I encountered up into the implementation of SourceCode

@The-Minecraft-Scientist The-Minecraft-Scientist changed the title Allow returning possibly-owned data from SpanContents::data returning owned data from SpanContents::data Nov 22, 2024
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