Skip to content
Myr

Add test of ensure through a Not impl

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 2b42f62 · Browse files · 1 file+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−0 removed

  • tests:+10 added−0 removed

1 file+10 added−0 removed

modified:tests/test_macros.rs+10 added
13 unmodified lines
14use self::common::*;15use anyhow::{anyhow, ensure, Result};16use std::cell::Cell;17use std::future;18use std::ops::Not;1920#[test]21fn test_messages() {22 assert_eq!("oh no!", bail_literal().unwrap_err().to_string());
37 unmodified lines
60 struct Struct {61 condition: bool,62 }6364 impl Not for Struct {65 type Output = bool;66 fn not(self) -> Self::Output {67 !self.condition68 }69 }7071 let s = Struct { condition: true };72 match &s {73 Struct { condition } => ensure!(condition), // &bool74 }7576 ensure!(s);7778 Ok(())79}8081#[test]
25 unmodified lines