docs: explain why the path placeholder is there

pull/24376/head
Marco Neumann 2021-07-08 14:41:49 +02:00
parent bc958e2ff0
commit 676034b4ae
1 changed files with 6 additions and 1 deletions

View File

@ -294,6 +294,8 @@ impl<W: Write> Runner<W> {
}
/// Return output path for input path.
///
/// This converts `some/prefix/in/foo.sql` (or other file extensions) to `some/prefix/out/foo.out`.
fn make_output_path(input: &Path) -> Result<PathBuf> {
let stem = input.file_stem().context(NoFileStem { path: input })?;
@ -306,7 +308,10 @@ fn make_output_path(input: &Path) -> Result<PathBuf> {
out.push("out");
// set file name and ext
out.push("placeholder"); // really confusing API
// The PathBuf API is somewhat confusing: `set_file_name` will replace the last component (which at this point is
// the "out"). However we wanna create a file out of the stem and the extension. So as a somewhat hackish
// workaround first push a placeholder that is then replaced.
out.push("placeholder");
out.set_file_name(stem);
out.set_extension("out");