-
Notifications
You must be signed in to change notification settings - Fork 6
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
File inclusion with an explicit destination path #11
base: main
Are you sure you want to change the base?
Conversation
src/lib.rs
Outdated
@@ -47,39 +48,45 @@ impl PrivateFS { | |||
}) | |||
} | |||
|
|||
pub fn include(&self, path: impl AsRef<Path>) -> Result<(), Box<dyn Error>> { | |||
pub fn include(&self, source_path: impl AsRef<Path>, destination_path: Option<&str>) -> Result<(), Box<dyn Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative here would be to add a generic parameter S: AsRef<Path>
and tie both inputs to use S
.
We cannot have destination_path: Option<impl AsRef<Path>>
because it causes an inference error when the path is omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukeMathWalker would it be possible to do this so they can be separate types or is the inference breaking here?
pub fn include(&self, source_path: S, destination_path: Option<D>)
where S: AsRef<Path>,
D: AsRef<Path>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still failed, but I managed to work around the inference issue by forcing D
to be PathBuf
in the code generated by the proc macro for the None
case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! 🤩 I think we can pass off on parsing errors for now as I don't have a great idea of what I want there, but overall these changes are fantastic! Let's take out the TODO
around the panic and if the double generic works let's do that!
…ce error by using the turbofish to force D=PathBuf when the destination path is unspecified.
Thanks for the review! |
As discussed in #9, this PR changes the behaviour of the
include
attribute:#[assay(include = ["folder/my_file.rs"])
will copy the file into the root folder of the test working directory (i.e.file.rs
);#[assay(include = [("folder/my_file.rs", "folder/my_renamed_file.rs"])
will instead use the specified destination path.I have a few questions on the implementation that I've left as TODO comment in the code. I'd appreciate your input there.
Closes #9