Skip to content

Commit cc7ad5f

Browse files
committed
docs(cargo): Provide pointers on how to cache
This helps with assert-rs#6.
1 parent 79435b5 commit cc7ad5f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/cargo.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
//! Simplify running `bin`s in a Cargo project.
22
//!
3-
//! # Examples
3+
//! `CommandCargoExt` is an extension trait for `std::process::Command` to easily launch a crate's
4+
//! binaries.
5+
//!
6+
//! In addition, the underlying functions for looking up the crate's binaries are exposed to allow
7+
//! for optimizations, if needed.
8+
//!
9+
//! # Simple Example
410
//!
511
//! ```rust
612
//! use assert_cmd::prelude::*;
@@ -11,6 +17,22 @@
1117
//! .unwrap()
1218
//! .unwrap();
1319
//! ```
20+
//!
21+
//! # Caching Example
22+
//!
23+
//! ```rust
24+
//! use assert_cmd::prelude::*;
25+
//!
26+
//! use std::process::Command;
27+
//!
28+
//! let bin_under_test = assert_cmd::cargo::main_binary_path().unwrap();
29+
//! Command::new(&bin_under_test)
30+
//! .unwrap();
31+
//! ```
32+
//!
33+
//! Tip: Use [`lazy_static][lazy_static] to cache `bin_under_test` across test functions.
34+
//!
35+
//! [lazy_static]: https://crates.io/crates/lazy_static
1436
1537
use std::error::Error;
1638
use std::ffi;

0 commit comments

Comments
 (0)