zkat / miette

Fancy extension for std::error::Error with pretty, detailed diagnostic printing.
https://docs.rs/miette
Apache License 2.0
2.05k stars 118 forks source link

returning owned data from `SpanContents::data` #410

Open The-Minecraft-Scientist opened 1 week ago

The-Minecraft-Scientist commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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