Skip to content

Commit 6598446

Browse files
committed
Revert deduping monormophization in Session
But keep the dedup for `{process_impl, native_mux_impl}::Session` since their implementation is complex. Signed-off-by: Jiahao XU <[email protected]>
1 parent 8a38cdd commit 6598446

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

src/session.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,7 @@ impl Session {
175175
/// If `program` is not an absolute path, the `PATH` will be searched in an OS-defined way on
176176
/// the host.
177177
pub fn command<'a, S: Into<Cow<'a, str>>>(&self, program: S) -> Command<'_> {
178-
fn inner<'s>(this: &'s Session, program: Cow<'_, str>) -> Command<'s> {
179-
this.raw_command(&*shell_escape::unix::escape(program))
180-
}
181-
182-
inner(self, program.into())
178+
self.raw_command(&*shell_escape::unix::escape(program.into()))
183179
}
184180

185181
/// Constructs a new [`Command`] for launching the program at path `program` on the remote
@@ -199,14 +195,10 @@ impl Session {
199195
/// If `program` is not an absolute path, the `PATH` will be searched in an OS-defined way on
200196
/// the host.
201197
pub fn raw_command<S: AsRef<OsStr>>(&self, program: S) -> Command<'_> {
202-
fn inner<'s>(this: &'s Session, program: &OsStr) -> Command<'s> {
203-
Command::new(
204-
this,
205-
delegate!(&this.0, imp, { imp.raw_command(program).into() }),
206-
)
207-
}
208-
209-
inner(self, program.as_ref())
198+
Command::new(
199+
self,
200+
delegate!(&self.0, imp, { imp.raw_command(program.as_ref()).into() }),
201+
)
210202
}
211203

212204
/// Constructs a new [`Command`] for launching subsystem `program` on the remote
@@ -260,14 +252,10 @@ impl Session {
260252
/// # Ok(()) }
261253
/// ```
262254
pub fn subsystem<S: AsRef<OsStr>>(&self, program: S) -> Command<'_> {
263-
fn inner<'s>(this: &'s Session, program: &OsStr) -> Command<'s> {
264-
Command::new(
265-
this,
266-
delegate!(&this.0, imp, { imp.subsystem(program).into() }),
267-
)
268-
}
269-
270-
inner(self, program.as_ref())
255+
Command::new(
256+
self,
257+
delegate!(&self.0, imp, { imp.subsystem(program.as_ref()).into() }),
258+
)
271259
}
272260

273261
/// Constructs a new [`Command`] that runs the provided shell command on the remote host.
@@ -310,13 +298,9 @@ impl Session {
310298
/// [this article]: https://mywiki.wooledge.org/Arguments
311299
/// [`shell-escape`]: https://crates.io/crates/shell-escape
312300
pub fn shell<S: AsRef<str>>(&self, command: S) -> Command<'_> {
313-
fn inner<'s>(this: &'s Session, command: &str) -> Command<'s> {
314-
let mut cmd = this.command("sh");
315-
cmd.arg("-c").arg(command);
316-
cmd
317-
}
318-
319-
inner(self, command.as_ref())
301+
let mut cmd = self.command("sh");
302+
cmd.arg("-c").arg(command.as_ref());
303+
cmd
320304
}
321305

322306
/// Request to open a local/remote port forwarding.

0 commit comments

Comments
 (0)