Skip to content

Commit 3a921b6

Browse files
committed
Revert dedup monomorphization in Command
Signed-off-by: Jiahao XU <[email protected]>
1 parent 6598446 commit 3a921b6

File tree

1 file changed

+20
-40
lines changed

1 file changed

+20
-40
lines changed

src/command.rs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ impl<'s> Command<'s> {
126126
///
127127
/// To pass multiple arguments see [`args`](Command::args).
128128
pub fn arg<S: AsRef<str>>(&mut self, arg: S) -> &mut Self {
129-
fn inner<'cmd, 's>(this: &'cmd mut Command<'s>, arg: &str) -> &'cmd mut Command<'s> {
130-
this.raw_arg(&*shell_escape::unix::escape(Cow::Borrowed(arg)))
131-
}
132-
133-
inner(self, arg.as_ref())
129+
self.raw_arg(&*shell_escape::unix::escape(Cow::Borrowed(arg.as_ref())))
134130
}
135131

136132
/// Adds an argument to pass to the remote program.
@@ -142,14 +138,10 @@ impl<'s> Command<'s> {
142138
///
143139
/// To pass multiple unescaped arguments see [`raw_args`](Command::raw_args).
144140
pub fn raw_arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
145-
fn inner<'cmd, 's>(this: &'cmd mut Command<'s>, arg: &OsStr) -> &'cmd mut Command<'s> {
146-
delegate!(&mut this.imp, imp, {
147-
imp.raw_arg(arg);
148-
});
149-
this
150-
}
151-
152-
inner(self, arg.as_ref())
141+
delegate!(&mut self.imp, imp, {
142+
imp.raw_arg(arg.as_ref());
143+
});
144+
self
153145
}
154146

155147
/// Adds multiple arguments to pass to the remote program.
@@ -197,15 +189,11 @@ impl<'s> Command<'s> {
197189
/// [`inherit`]: struct.Stdio.html#method.inherit
198190
/// [`null`]: struct.Stdio.html#method.null
199191
pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
200-
fn inner<'cmd, 's>(this: &'cmd mut Command<'s>, cfg: Stdio) -> &'cmd mut Command<'s> {
201-
delegate!(&mut this.imp, imp, {
202-
imp.stdin(cfg);
203-
});
204-
this.stdin_set = true;
205-
this
206-
}
207-
208-
inner(self, cfg.into())
192+
delegate!(&mut self.imp, imp, {
193+
imp.stdin(cfg.into());
194+
});
195+
self.stdin_set = true;
196+
self
209197
}
210198

211199
/// Configuration for the remote process's standard output (stdout) handle.
@@ -216,15 +204,11 @@ impl<'s> Command<'s> {
216204
/// [`inherit`]: struct.Stdio.html#method.inherit
217205
/// [`piped`]: struct.Stdio.html#method.piped
218206
pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
219-
fn inner<'cmd, 's>(this: &'cmd mut Command<'s>, cfg: Stdio) -> &'cmd mut Command<'s> {
220-
delegate!(&mut this.imp, imp, {
221-
imp.stdout(cfg);
222-
});
223-
this.stdout_set = true;
224-
this
225-
}
226-
227-
inner(self, cfg.into())
207+
delegate!(&mut self.imp, imp, {
208+
imp.stdout(cfg.into());
209+
});
210+
self.stdout_set = true;
211+
self
228212
}
229213

230214
/// Configuration for the remote process's standard error (stderr) handle.
@@ -235,15 +219,11 @@ impl<'s> Command<'s> {
235219
/// [`inherit`]: struct.Stdio.html#method.inherit
236220
/// [`piped`]: struct.Stdio.html#method.piped
237221
pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
238-
fn inner<'cmd, 's>(this: &'cmd mut Command<'s>, cfg: Stdio) -> &'cmd mut Command<'s> {
239-
delegate!(&mut this.imp, imp, {
240-
imp.stderr(cfg);
241-
});
242-
this.stderr_set = true;
243-
this
244-
}
245-
246-
inner(self, cfg.into())
222+
delegate!(&mut self.imp, imp, {
223+
imp.stderr(cfg.into());
224+
});
225+
self.stderr_set = true;
226+
self
247227
}
248228

249229
async fn spawn_impl(&mut self) -> Result<RemoteChild<'s>, Error> {

0 commit comments

Comments
 (0)