1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//! The `foot-gun` crate is a joke library inspired by [this twitter thread](https://twitter.com/flukejones/status/1417241932154081294) /// The `foot_gun` macro for unsafe code. /// /// Inspired by a comment from [@flukejones](https://twitter.com/flukejones/status/1417241932154081294) /// /// ## Usage /// ``` /// foot_gun!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! foot_gun { ($e:block) => { unsafe { $e } }; } /// The `here_be_dragons` macro for unsafe code. /// /// Inspired by a comment from [@ekuber](https://twitter.com/ekuber/status/1417243264315387908) /// /// ## Usage /// ``` /// here_be_dragons!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! here_be_dragons { ($e:block) => { unsafe { $e } }; } /// The `beware` macro for unsafe code. /// /// Inspired by a comment from [@NikolaiVazquez](https://twitter.com/NikolaiVazquez/status/1417253654508212225) /// /// ## Usage /// ``` /// beware!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! beware { ($e:block) => { unsafe { $e } }; } /// The `behold` macro for unsafe code. /// /// Inspired by a comment from [@fasterthanlime](https://twitter.com/fasterthanlime/status/1417370585072611352) /// /// ## Usage /// ``` /// behold!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! behold { ($e:block) => { unsafe { $e } }; } /// The `en_garde` macro for unsafe code. /// /// Inspired by a comment from [@redtwitdown](https://twitter.com/redtwitdown/status/1417372091599314946) /// /// ## Usage /// ``` /// en_garde!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! en_garde { ($e:block) => { unsafe { $e } }; } /// The `i_got_this` macro for unsafe code. /// /// Inspired by a comment from [@algo_luca](https://twitter.com/algo_luca/status/1417397666225561600) /// /// ## Usage /// ``` /// i_got_this!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! i_got_this { ($e:block) => { unsafe { $e } }; } /// The `hold_my_borrowchk` macro for unsafe code. /// /// Inspired by a comment from [@redtwitdown](https://twitter.com/redtwitdown/status/1417398144585715713) /// /// ## Usage /// ``` /// hold_my_borrowchk!({ /// // Unsafe code here /// } /// ``` #[macro_export] macro_rules! hold_my_borrowchk { ($e:block) => { unsafe { $e } }; } #[cfg(test)] mod tests { use super::*; #[test] #[allow(unused_unsafe)] pub fn test_compile() { foot_gun!({ println!("Hello") }); here_be_dragons!({ println!("Hello") }); beware!({ println!("Hello") }); behold!({ println!("Hello") }); en_garde!({ println!("Hello") }); i_got_this!({ println!("Hello") }); hold_my_borrowchk!({ println!("Hello") }); } }