File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 53
53
toolchain : ${{ env.RUST_TOOLCHAIN }}
54
54
components : rustfmt, clippy
55
55
- uses : Swatinem/rust-cache@v1
56
- - run : cargo test --lib
56
+ - run : cargo test
57
57
58
58
doc :
59
59
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -103,7 +103,21 @@ macro_rules! assert_owner {
103
103
} ;
104
104
}
105
105
106
- /// Ensures an [Option] can be unwrapped, otherwise returns the error
106
+ /// Ensures an [Option] can be unwrapped, otherwise returns the error.
107
+ ///
108
+ /// # Example
109
+ ///
110
+ /// ```should_panic
111
+ /// # use anchor_lang::prelude::*;
112
+ /// # impl From<ErrorCode> for ProgramError { fn from(code: ErrorCode) -> Self { ProgramError::Custom(10) } }
113
+ /// # pub enum ErrorCode { MyError }
114
+ /// # #[macro_use] extern crate vipers; fn main() -> ProgramResult {
115
+ /// let one = 1_u64;
116
+ /// let two = 2_u64;
117
+ /// let my_value = unwrap_or_err!(one.checked_sub(2), MyError); // throws an error
118
+ /// Ok(())
119
+ /// # }
120
+ /// ```
107
121
#[ macro_export]
108
122
macro_rules! unwrap_or_err {
109
123
( $option: expr, $error: tt $( , ) ?) => {
You can’t perform that action at this time.
0 commit comments