@@ -20,18 +20,17 @@ macro_rules! syscall {
20
20
} ;
21
21
}
22
22
23
- /// Macro version of `syscall1`.
23
+ /// Macro version of `syscall1`
24
24
#[ macro_export]
25
25
macro_rules! syscall1 {
26
26
( $nr: ident, $a1: expr) => {
27
27
$crate:: syscall1( $crate:: nr:: $nr, $a1 as usize )
28
28
} ;
29
29
}
30
30
31
- /// Macro for printing to the HOST standard output.
31
+ /// Macro for printing to the HOST standard output
32
32
///
33
- /// This is similar to the `print!` macro in the standard library. Both will panic on any failure to
34
- /// print.
33
+ /// This macro returns a `Result<(), ()>` value
35
34
#[ macro_export]
36
35
macro_rules! hprint {
37
36
( $s: expr) => {
@@ -44,8 +43,7 @@ macro_rules! hprint {
44
43
45
44
/// Macro for printing to the HOST standard output, with a newline.
46
45
///
47
- /// This is similar to the `println!` macro in the standard library. Both will panic on any failure to
48
- /// print.
46
+ /// This macro returns a `Result<(), ()>` value
49
47
#[ macro_export]
50
48
macro_rules! hprintln {
51
49
( ) => {
@@ -59,10 +57,9 @@ macro_rules! hprintln {
59
57
} ;
60
58
}
61
59
62
- /// Macro for printing to the HOST standard error.
60
+ /// Macro for printing to the HOST standard error
63
61
///
64
- /// This is similar to the `eprint!` macro in the standard library. Both will panic on any failure
65
- /// to print.
62
+ /// This macro returns a `Result<(), ()>` value
66
63
#[ macro_export]
67
64
macro_rules! heprint {
68
65
( $s: expr) => {
@@ -75,8 +72,7 @@ macro_rules! heprint {
75
72
76
73
/// Macro for printing to the HOST standard error, with a newline.
77
74
///
78
- /// This is similar to the `eprintln!` macro in the standard library. Both will panic on any failure
79
- /// to print.
75
+ /// This macro returns a `Result<(), ()>` value
80
76
#[ macro_export]
81
77
macro_rules! heprintln {
82
78
( ) => {
@@ -90,23 +86,22 @@ macro_rules! heprintln {
90
86
} ;
91
87
}
92
88
93
- /// Macro that prints and returns the value of a given expression for quick and
94
- /// dirty debugging.
95
- ///
96
- /// Works exactly like `dbg!` in the standard library, replacing `eprintln!`
97
- /// with `heprintln!`.
89
+ /// Macro that prints and returns the value of a given expression
90
+ /// for quick and dirty debugging. Works exactly like `dbg!` in
91
+ /// the standard library, replacing `eprintln` with `heprintln`,
92
+ /// which it unwraps.
98
93
#[ macro_export]
99
94
macro_rules! dbg {
100
95
( ) => {
101
- $crate:: heprintln!( "[{}:{}]" , file!( ) , line!( ) ) ;
96
+ $crate:: heprintln!( "[{}:{}]" , file!( ) , line!( ) ) . unwrap ( ) ;
102
97
} ;
103
98
( $val: expr) => {
104
99
// Use of `match` here is intentional because it affects the lifetimes
105
100
// of temporaries - https://stackoverflow.com/a/48732525/1063961
106
101
match $val {
107
102
tmp => {
108
103
$crate:: heprintln!( "[{}:{}] {} = {:#?}" ,
109
- file!( ) , line!( ) , stringify!( $val) , & tmp) ;
104
+ file!( ) , line!( ) , stringify!( $val) , & tmp) . unwrap ( ) ;
110
105
tmp
111
106
}
112
107
}
0 commit comments