I am porting a library banana-rdf to Scala3. The library aims to provide a no-cost efficient interface for RDF libraries written in Scala, JS (and hopefully even native at some point).
I am currently working on the implementation for the Jena library that returns AutoCloseable iterators, which made me wonder how I should best deal with those.
- If I convert that type to an scala
Iterablethen I loose the closeable interface on it, losing the information that the caller should make sure to close it before using it; - I looked at
scala.util.Using, but that requires the resource to be iterated through, which is something for the calling code to determine, not the library; - should one just return the Java iterator? But I would need to check if that plays well with ScalaJS code
- Other ideas?