Sure, but isn’t this in a dependency? Can’t be reached when only importing your crate anyways? And if you’re building a binary, I don’t think this could really considered exported, is what I mean :)
Actually, dead code eliminination should do the trick, if you’re compiling a binary at least (same for a library I think, but there could be re-exports there). Did you compile in release mode?
Huh, I did not know that you can speed up builds by stripping debug info, need to try that out :)
Yeah I was very happy to find that out. I was calling latex externally before, and there was a lot of pain interacting with the filesystem and temporary files. Now it all happens in-memory :)
One thing that prevents me from letting users build their own templates is the scripting capabilities. A joker creating an endless loop could block the whole server.
I know little about servers, but can’t you run the generation in a thread with a timeout or so? Or maybe compile to wasm and let the generation run on the users machines? I also know little about wasm, but I’d have guessed it has facilities to keep runtime and load under control.
What would be nice is a “safe” mode in which no access to the file system (include and sorts) and limited runtime makes it safe to let users build their own templates.
Ah, are you by chance shelling out to the typst binary? You can actually use typst as a library, and then you’ve got full control over the files involved, so it’s “safe” in that respect.
Alas, on the whole the compiler slowed down as a result of this. I think it’s a worthy tradeoff though.
unsafe
does not disable the borrow checker. It does however give you abilities to circumvent it, namely by letting you dereference pointers, which are not subject to the borrow checker.