Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
Signed-off-by: TXXT <[email protected]>
  • Loading branch information
hunterlxt committed May 19, 2020
1 parent 60f598c commit b522664
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
//! I/O panic:
//!
//! ```rust
//! use fail::{fail_point, FailScenario};
//! use fail::fail_point;
//!
//! fn do_fallible_work() {
//! fail_point!("read-dir");
//! let _dir: Vec<_> = std::fs::read_dir(".").unwrap().collect();
//! // ... do some work on the directory ...
//! }
//!
//! let scenario = FailScenario::setup();
//! fail::setup();
//! do_fallible_work();
//! scenario.teardown();
//! fail::teardown();
//! println!("done");
//! ```
//!
Expand Down Expand Up @@ -82,7 +82,7 @@
//! Here's a basic pattern for writing unit tests tests with fail points:
//!
//! ```rust
//! use fail::{fail_point, FailScenario};
//! use fail::fail_point;
//!
//! fn do_fallible_work() {
//! fail_point!("read-dir");
Expand All @@ -93,12 +93,12 @@
//! #[test]
//! #[should_panic]
//! fn test_fallible_work() {
//! let scenario = FailScenario::setup();
//! fail::setup();
//! fail::cfg("read-dir", "panic").unwrap();
//!
//! do_fallible_work();
//!
//! scenario.teardown();
//! fail::teardown();
//! }
//! ```
//!
Expand Down Expand Up @@ -131,7 +131,7 @@
//! function we used earlier to return a `Result`:
//!
//! ```rust
//! use fail::{fail_point, FailScenario};
//! use fail::fail_point;
//! use std::io;
//!
//! fn do_fallible_work() -> io::Result<()> {
Expand All @@ -142,9 +142,9 @@
//! }
//!
//! fn main() -> io::Result<()> {
//! let scenario = FailScenario::setup();
//! fail::setup();
//! do_fallible_work()?;
//! scenario.teardown();
//! fail::teardown();
//! println!("done");
//! Ok(())
//! }
Expand Down Expand Up @@ -653,13 +653,12 @@ pub fn eval<R, F: FnOnce(Option<String>) -> R>(name: &str, f: F) -> Option<R> {
let id = thread::current().id();
let group = REGISTRY_GROUP.read().unwrap();

let registry = group
.get(&id)
.unwrap_or(&REGISTRY_GLOBAL.registry)
.read()
.unwrap();

let p = {
let registry = group
.get(&id)
.unwrap_or(&REGISTRY_GLOBAL.registry)
.read()
.unwrap();
match registry.get(name) {
None => return None,
Some(p) => p.clone(),
Expand Down

0 comments on commit b522664

Please sign in to comment.