From f78d2fa7a1f195eabcb0f4909005730f013334be Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 26 Jul 2018 21:10:58 -0600 Subject: [PATCH] docs(cargo): Provide pointers on how to cache This helps with #6. --- src/cargo.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cargo.rs b/src/cargo.rs index b83f588..769311f 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -1,6 +1,12 @@ //! Simplify running `bin`s in a Cargo project. //! -//! # Examples +//! `CommandCargoExt` is an extension trait for `std::process::Command` to easily launch a crate's +//! binaries. +//! +//! In addition, the underlying functions for looking up the crate's binaries are exposed to allow +//! for optimizations, if needed. +//! +//! # Simple Example //! //! ```rust //! use assert_cmd::prelude::*; @@ -11,6 +17,22 @@ //! .unwrap() //! .unwrap(); //! ``` +//! +//! # Caching Example +//! +//! ```rust +//! use assert_cmd::prelude::*; +//! +//! use std::process::Command; +//! +//! let bin_under_test = assert_cmd::cargo::main_binary_path().unwrap(); +//! Command::new(&bin_under_test) +//! .unwrap(); +//! ``` +//! +//! Tip: Use [`lazy_static][lazy_static] to cache `bin_under_test` across test functions. +//! +//! [lazy_static]: https://crates.io/crates/lazy_static use std::error::Error; use std::ffi;