Skip to content

Commit 72c78cd

Browse files
committed
Rename wait_cmd/wait_fun functions
To wait_cmd_result() and wait_fun_result() functions to make it clearer
1 parent fd493af commit 72c78cd

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ println!("get result: {}", run_fun!(my_cmd)?);
229229
`spawn!()` macro executes the whole command as a child process, returning a handle to it. By
230230
default, stdin, stdout and stderr are inherited from the parent.
231231

232-
To get result, you can call `wait_cmd()` or `wait_fun()` to get CmdResult/FunResult.
232+
To get result, you can call `wait_cmd_result()` or `wait_fun_result()` to get CmdResult/FunResult.
233233

234234
```rust
235-
spawn!(ping -c 10 192.168.0.1)?.wait_cmd()?;
236-
let output = spawn!(/bin/cat file.txt | sed s/a/b/)?.wait_fun()?;
235+
spawn!(ping -c 10 192.168.0.1)?.wait_cmd_result()?;
236+
let output = spawn!(/bin/cat file.txt | sed s/a/b/)?.wait_fun_result()?;
237237
```
238238

239239

macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn run_fun(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
173173
///
174174
/// let handle = spawn!(ping -c 10 192.168.0.1)?;
175175
/// // ...
176-
/// if handle.wait_cmd().is_err() {
176+
/// if handle.wait_cmd_result().is_err() {
177177
/// // ...
178178
/// }
179179
/// # Ok::<(), std::io::Error>(())

src/child.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ impl CmdChildren {
1212
Self(children)
1313
}
1414

15-
pub fn wait_cmd(&mut self) -> CmdResult {
16-
let ret = self.wait_cmd_nolog();
15+
pub fn wait_cmd_result(&mut self) -> CmdResult {
16+
let ret = self.wait_cmd_result_nolog();
1717
if let Err(ref err) = ret {
1818
error!(
1919
"Running {} failed, Error: {}",
@@ -24,7 +24,7 @@ impl CmdChildren {
2424
ret
2525
}
2626

27-
pub(crate) fn wait_cmd_nolog(&mut self) -> CmdResult {
27+
pub(crate) fn wait_cmd_result_nolog(&mut self) -> CmdResult {
2828
// wait last process result
2929
let handle = self.0.pop().unwrap();
3030
handle.wait(true)?;
@@ -66,8 +66,8 @@ impl CmdChildren {
6666
}
6767
}
6868

69-
pub fn wait_fun(&mut self) -> FunResult {
70-
let ret = self.wait_fun_nolog();
69+
pub fn wait_fun_result(&mut self) -> FunResult {
70+
let ret = self.wait_fun_result_nolog();
7171
if let Err(ref err) = ret {
7272
error!(
7373
"Running {} failed, Error: {}",
@@ -78,7 +78,7 @@ impl CmdChildren {
7878
ret
7979
}
8080

81-
pub(crate) fn wait_fun_nolog(&mut self) -> FunResult {
81+
pub(crate) fn wait_fun_result_nolog(&mut self) -> FunResult {
8282
// wait last process result
8383
let handle = self.0.pop().unwrap();
8484
let wait_last = handle.wait_with_output();

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@
254254
//! `spawn!()` macro executes the whole command as a child process, returning a handle to it. By
255255
//! default, stdin, stdout and stderr are inherited from the parent.
256256
//!
257-
//! To get result, you can call `wait_cmd()` or `wait_fun()` to get CmdResult/FunResult.
257+
//! To get result, you can call `wait_cmd_result()` or `wait_fun_result()` to get CmdResult/FunResult.
258258
//!
259259
//! ```no_run
260260
//! # use cmd_lib::spawn;
261-
//! spawn!(ping -c 10 192.168.0.1)?.wait_cmd()?;
262-
//! let output = spawn!(/bin/cat file.txt | sed s/a/b/)?.wait_fun()?;
261+
//! spawn!(ping -c 10 192.168.0.1)?.wait_cmd_result()?;
262+
//! let output = spawn!(/bin/cat file.txt | sed s/a/b/)?.wait_fun_result()?;
263263
//! # Ok::<(), std::io::Error>(())
264264
//! ```
265265
//!

src/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ impl Cmds {
196196
}
197197

198198
fn run_cmd(&mut self, current_dir: &mut String) -> CmdResult {
199-
self.spawn(current_dir)?.wait_cmd_nolog()
199+
self.spawn(current_dir)?.wait_cmd_result_nolog()
200200
}
201201

202202
fn run_fun(&mut self, current_dir: &mut String) -> FunResult {
203-
self.spawn(current_dir)?.wait_fun_nolog()
203+
self.spawn(current_dir)?.wait_fun_result_nolog()
204204
}
205205
}
206206

0 commit comments

Comments
 (0)