add brief doc to some macro (#2523)

* add doc

* Update lib.rs
This commit is contained in:
thiolliere
2019-05-10 14:21:03 +02:00
committed by Gavin Wood
parent 363448cd01
commit ac195a0060
+21
View File
@@ -66,6 +66,9 @@ pub use runtime_io::print;
#[doc(inline)]
pub use srml_support_procedural::decl_storage;
/// Return Err of the expression: `return Err($expression);`.
///
/// Used as `fail!(expression)`.
#[macro_export]
macro_rules! fail {
( $y:expr ) => {{
@@ -73,6 +76,9 @@ macro_rules! fail {
}}
}
/// Evaluate `$x:expr` and if not true return `Err($y:expr)`.
///
/// Used as `ensure!(expression_to_ensure, expression_to_return_on_false)`.
#[macro_export]
macro_rules! ensure {
( $x:expr, $y:expr ) => {{
@@ -82,6 +88,10 @@ macro_rules! ensure {
}}
}
/// Evaluate an expression, assert it returns an expected `Err` value and that
/// runtime storage has not been mutated (i.e. expression is a no-operation).
///
/// Used as `assert_noop(expression_to_assert, expected_error_expression)`.
#[macro_export]
#[cfg(feature = "std")]
macro_rules! assert_noop {
@@ -92,6 +102,13 @@ macro_rules! assert_noop {
}
}
/// Panic if an expression doesn't evaluate to an `Err`.
///
/// Used as `assert_err!(expression_to_assert, expected_err_expression)`.
/// Assert an expression returns an error specified.
///
/// Used as `assert_err!(expression_to_assert, expected_error_expression)`
#[macro_export]
#[cfg(feature = "std")]
macro_rules! assert_err {
@@ -100,6 +117,10 @@ macro_rules! assert_err {
}
}
/// Panic if an expression doesn't evaluate to `Ok`.
///
/// Used as `assert_ok!(expression_to_assert, expected_ok_expression)`,
/// or `assert_ok!(expression_to_assert)` which would assert against `Ok(())`.
#[macro_export]
#[cfg(feature = "std")]
macro_rules! assert_ok {