Skip to content

Commit

Permalink
Add test of ensure with a &bool argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 17, 2024
1 parent 96f0392 commit 5152c1d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mod common;

use self::common::*;
use anyhow::{anyhow, ensure};
use anyhow::{anyhow, ensure, Result};
use std::cell::Cell;
use std::future;

Expand Down Expand Up @@ -53,6 +53,22 @@ fn test_ensure() {
);
}

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

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

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

#[test]
fn test_temporaries() {
fn require_send_sync(_: impl Send + Sync) {}
Expand Down

0 comments on commit 5152c1d

Please sign in to comment.