File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,6 @@ standard library includes an assortment of useful macros.
15
15
- ` dbg!(expression) ` logs the value of the expression and returns it.
16
16
- ` todo!() ` marks a bit of code as not-yet-implemented. If executed, it will
17
17
panic.
18
- - ` unreachable!() ` marks a bit of code as unreachable. If executed, it will
19
- panic.
20
18
21
19
``` rust,editable
22
20
fn factorial(n: u32) -> u32 {
@@ -46,4 +44,19 @@ especially critical.
46
44
The course does not cover defining macros, but a later section will describe use
47
45
of derive macros.
48
46
47
+ ## More To Explore
48
+
49
+ There are a number of other useful macros provided by the standard library. Some
50
+ other examples you can share with students if they want to know more:
51
+
52
+ - [ ` assert! ` ] and related macros can be used to add assertions to your code.
53
+ These are used heavily in writing tests.
54
+ - [ ` unreachable! ` ] is used to mark a branch of control flow that should never be
55
+ hit.
56
+ - [ ` eprintln! ` ] allows you to print to stderr.
57
+
49
58
</details >
59
+
60
+ [ `assert!` ] : https://doc.rust-lang.org/stable/std/macro.assert.html
61
+ [ `unreachable!` ] : https://doc.rust-lang.org/stable/std/macro.unreachable.html
62
+ [ `eprintln!` ] : https://doc.rust-lang.org/stable/std/macro.eprintln.html
You can’t perform that action at this time.
0 commit comments