Skip to content

Commit

Permalink
Simplify nonbool ensure test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 17, 2024
1 parent 3f9c220 commit 2b42f62
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,17 @@ fn test_ensure() {
}

#[test]
fn test_ensure_nonbool() {
fn test_ensure_nonbool() -> Result<()> {
struct Struct {
condition: bool,
}

fn f(s: &Struct) -> Result<()> {
match s {
Struct { condition } => ensure!(condition), // &bool
}
Ok(())
let s = Struct { condition: true };
match &s {
Struct { condition } => ensure!(condition), // &bool
}

f(&Struct { condition: true }).unwrap();
Ok(())
}

#[test]
Expand Down

0 comments on commit 2b42f62

Please sign in to comment.