Skip to content

Commit c0296ad

Browse files
committed
Fix doc feature labels by creating inner mods
1 parent d13d53c commit c0296ad

3 files changed

Lines changed: 38 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "send_ctrlc"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["Scott Meeuwsen <smeeuwsen@gmail.com>"]
55
license = "MIT OR Apache-2.0"
66
description = "A cross platform crate for sending ctrl-c to child processes"

src/lib.rs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,35 +73,53 @@ impl InterruptablePid for tokio::process::Child {
7373
}
7474

7575
/// Create a new interruptable command
76-
#[cfg(unix)]
7776
pub fn new_command<S: AsRef<OsStr>>(program: S) -> Command {
78-
Command::new(program)
77+
inner::new_command(program)
7978
}
8079

81-
/// Create a new interruptable command
82-
#[cfg(windows)]
83-
pub fn new_command<S: AsRef<OsStr>>(program: S) -> Command {
84-
use std::os::windows::process::CommandExt as _;
80+
mod inner {
81+
use std::{ffi::OsStr, process::Command};
8582

86-
let mut command = Command::new(program);
87-
command.creation_flags(CREATE_NEW_PROCESS_GROUP);
88-
command
83+
#[cfg(windows)]
84+
pub fn new_command<S: AsRef<OsStr>>(program: S) -> Command {
85+
use std::os::windows::process::CommandExt as _;
86+
87+
let mut command = Command::new(program);
88+
command.creation_flags(crate::CREATE_NEW_PROCESS_GROUP);
89+
command
90+
}
91+
92+
#[cfg(unix)]
93+
pub fn new_command<S: AsRef<OsStr>>(program: S) -> Command {
94+
use std::process::Command;
95+
96+
Command::new(program)
97+
}
8998
}
9099

91100
/// Create a new interruptable tokio command
92101
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
93-
#[cfg(all(feature = "tokio", target_family = "windows"))]
102+
#[cfg(feature = "tokio")]
94103
pub fn new_tokio_command<S: AsRef<OsStr>>(program: S) -> tokio::process::Command {
95-
let mut command = tokio::process::Command::new(program);
96-
command.creation_flags(CREATE_NEW_PROCESS_GROUP);
97-
command
104+
inner_tokio::new_tokio_command(program)
98105
}
99106

100-
/// Create a new interruptable tokio command
101-
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
102-
#[cfg(all(feature = "tokio", target_family = "unix"))]
103-
pub fn new_tokio_command<S: AsRef<OsStr>>(program: S) -> tokio::process::Command {
104-
tokio::process::Command::new(program)
107+
#[cfg(feature = "tokio")]
108+
mod inner_tokio {
109+
use std::ffi::OsStr;
110+
use tokio::process::Command;
111+
112+
#[cfg(windows)]
113+
pub fn new_tokio_command<S: AsRef<OsStr>>(program: S) -> Command {
114+
let mut command = Command::new(program);
115+
command.creation_flags(crate::CREATE_NEW_PROCESS_GROUP);
116+
command
117+
}
118+
119+
#[cfg(unix)]
120+
pub fn new_tokio_command<S: AsRef<OsStr>>(program: S) -> Command {
121+
Command::new(program)
122+
}
105123
}
106124

107125
#[cfg(test)]

0 commit comments

Comments
 (0)