-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile time file path check which never fails? #67
Comments
Can you elaborate on what you are asking for? Maybe also provide some examples and why you believe |
For example, use include_dir::{include_dir, Dir};
static PROJECT_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR");
// of course, you can retrieve a file by its full path
let lib_rs = PROJECT_DIR.get_file("src/lib.rs"); // no unwrap needed, cost removed if possible as well maybe with `const`? Since we should already know if the file exists at compile time it would be better if we get compile time error that file does not exists rather than runtime error. Means that it is checked during compile time, also some costs for searching the file using string should be removed. |
The only way to guarantee this will succeed at compile time is if This sort of compile-time validation means we can't have things like compression because they will generally require allocations. There's also no point decompressing something at compile time because that'll just store the decompressed data in your variable. Also, how would you deal with things like a web server which is serving static assets that were compiled into the binary? Your |
But what if you store a token to the compressed data? But the data is still decompressed in runtime? But yeah, I don't know if it is possible to do this or not.
That was what I thought about which is similar to actix-web extractor. Just because some of the types is not available at compile time, everything is checked in runtime. What if there is a separation between two of them, one for those that want to check during compile time and one that can be used to dynamically checked? |
And the query could be zero cost?
The text was updated successfully, but these errors were encountered: