Skip to content

Commit 8fbd693

Browse files
committed
explicit drop semantics
1 parent d319702 commit 8fbd693

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

git2-hooks/src/hookspath.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ impl HookPaths {
176176
.stderr(std::process::Stdio::piped())
177177
.spawn()?;
178178

179-
if let Some(input) = stdin {
179+
if let Some(mut stdin_handle) = child.stdin.take() {
180180
use std::io::Write;
181-
if let Some(mut stdin_handle) = child.stdin.take() {
181+
if let Some(input) = stdin {
182182
stdin_handle.write_all(input)?;
183183
}
184+
drop(stdin_handle);
184185
}
185186

186187
child.wait_with_output()

src/clipboard.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ fn exec_copy_with_args(
2626
.spawn()
2727
.map_err(|e| anyhow!("`{command:?}`: {e:?}"))?;
2828

29-
process
29+
let mut stdin = process
3030
.stdin
31-
.as_mut()
32-
.ok_or_else(|| anyhow!("`{command:?}`"))?
31+
.take()
32+
.ok_or_else(|| anyhow!("`{command:?}`"))?;
33+
34+
stdin
3335
.write_all(text.as_bytes())
3436
.map_err(|e| anyhow!("`{command:?}`: {e:?}"))?;
37+
drop(stdin);
3538

3639
let out = process
3740
.wait_with_output()

0 commit comments

Comments
 (0)