zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.79k stars 78 forks source link

Allow `Cache`s to return a name borrowed from themselves #130

Closed ISSOtm closed 2 months ago

ISSOtm commented 2 months ago

This is useful when the name comes not from the handle, but from the cache itself.

For example, if the cache is a sort of Vec<{name: String, contents: Source<...>}> (then the handles are usizes).

ISSOtm commented 2 months ago

Never mind, this works with my own code, but not all of ariadne's. I tried another fix, but it breaks when trying to write (because fetch takes a &mut self, which gets extended by the result's lifetime extending that ref[^v2]). So I'll close this. Sorry!

[^v2]: This can be fixed by fetch returning the self back immutably, but would be a breaking change to the trait's signature. @zesterer, if I'm correct, you want ariadne 2.0 to use a different architecture in the ariadne2 branch, right?

zesterer commented 2 months ago

if I'm correct, you want ariadne 2.0 to use a different architecture in the ariadne2 branch, right?

Yes, I think there are several fundamental problems with Source/Cache.