File inclusion with an explicit destination path#11
File inclusion with an explicit destination path#11LukeMathWalker wants to merge 7 commits intomgattozzi:mainfrom
Conversation
src/lib.rs
Outdated
| } | ||
|
|
||
| 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.
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.
@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.
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.
mgattozzi
left a comment
There was a problem hiding this comment.
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! |
c5614a4 to
60790a7
Compare
As discussed in #9, this PR changes the behaviour of the
includeattribute:#[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