Skip to content

Commit 7f8140e

Browse files
de-vri-esjakoschiko
authored andcommitted
Add more documentation to AssertInfo and related types.
1 parent 9596fce commit 7f8140e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

library/core/src/panic/assert_info.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,41 @@ pub struct AssertInfo<'a> {
99
pub message: Option<crate::fmt::Arguments<'a>>,
1010
}
1111

12+
/// Details about the expression that failed an assertion.
1213
#[derive(Debug)]
1314
pub enum Assertion<'a> {
14-
/// The assertion is a boolean assertion.
15+
/// The failed assertion is a boolean expression.
16+
///
17+
/// This variant is only used for expressions that can't be described more specifically
18+
/// by another variant.
1519
Bool(BoolAssertion),
16-
/// The assertion is a binary comparison assertion.
20+
21+
/// The failed assertion is a binary comparison expression.
22+
///
23+
/// This is used by `assert_eq!()`, `assert_ne!()` and expressions like
24+
/// `assert!(x > 10)`.
1725
Binary(BinaryAssertion<'a>),
1826
}
1927

2028
/// Information about a failed boolean assertion.
29+
///
30+
/// The expression was asserted to be true, but it evaluated to false.
31+
///
32+
/// This struct is only used for assertion failures that can't be described more specifically
33+
/// by another assertion type.
2134
#[derive(Debug)]
2235
pub struct BoolAssertion {
23-
/// The expression that was evaluated.
36+
/// The expression that was evaluated to false.
2437
pub expr: &'static str,
2538
}
2639

2740
/// Information about a failed binary comparison assertion.
41+
///
42+
/// The left expression was compared with the right expression using `op`,
43+
/// and the comparison evaluted to false.
44+
///
45+
/// This struct is used for `assert_eq!()`, `assert_ne!()` and expressions like
46+
/// `assert!(x > 10)`.
2847
#[derive(Debug)]
2948
pub struct BinaryAssertion<'a> {
3049
/// The operator used to compare left and right.

0 commit comments

Comments
 (0)