rhai icon indicating copy to clipboard operation
rhai copied to clipboard

Why does Engine::eval_file_with_scope use PathBuf instead of Path?

Open starovoid opened this issue 3 years ago • 4 comments

Why is the file path passed to Engine::eval_file_with_scope as PathBuf instead of Path? I'm a little surprised by this decision, because it can provoke an extra allocation.

starovoid avatar Jan 19 '23 14:01 starovoid

Well, for historical reasons... The API is fixed so I can't easily change it to Path without breaking code.

It probably should be changed to a generic impl Into<Path>

schungx avatar Jan 20 '23 00:01 schungx

Thanks for the quick response, I hope these changes will come someday. And... Can I contribute to this?

starovoid avatar Jan 20 '23 08:01 starovoid

Of course. Your contributions are welcome.

Actually very few people use the file API (I guess) so it may actually not be very risky to change...

But of course being as compatible as possible is best.

schungx avatar Jan 20 '23 08:01 schungx

I opened the pull request with these changes

starovoid avatar Jan 21 '23 14:01 starovoid