File tree 1 file changed +24
-6
lines changed
1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,30 @@ Below is shown an example where an application has a different panicking behavio
17
17
whether is compiled using the dev profile (` cargo build ` ) or using the release profile (`cargo build
18
18
--release`).
19
19
20
- ``` rust
21
- // crate: panic-semihosting -- log panic message to the host stderr using semihosting
20
+ ``` rust, ignore
21
+ // crate: panic-semihosting -- log panic messages to the host stderr using semihosting
22
22
23
23
#![no_std]
24
24
25
+ use core::fmt::{Write, self};
26
+ use core::panic::PanicInfo;
27
+
28
+ struct HStderr {
29
+ // ..
30
+ # _0: (),
31
+ }
32
+ #
33
+ # impl HStderr {
34
+ # fn new() -> HStderr { HStderr { _0: () } }
35
+ # }
36
+ #
37
+ # impl fmt::Write for HStderr {
38
+ # fn write_str(&mut self, _: &str) -> fmt::Result { Ok(()) }
39
+ # }
40
+
25
41
#[panic_handler]
26
42
fn panic(info: &PanicInfo) -> ! {
27
- let host_stderr = /* .. */ ;
43
+ let mut host_stderr = HStderr::new() ;
28
44
29
45
// logs "panicked at '$reason', src/main.rs:27:4" to the host stderr
30
46
writeln!(host_stderr, "{}", info).ok();
@@ -33,18 +49,20 @@ fn panic(info: &PanicInfo) -> ! {
33
49
}
34
50
```
35
51
36
- ``` rust
52
+ ``` rust, ignore
37
53
// crate: panic-halt -- halt the thread on panic; messages are discarded
38
54
39
55
#![no_std]
40
56
57
+ use core::panic::PanicInfo;
58
+
41
59
#[panic_handler]
42
- fn panic (info : & PanicInfo ) -> ! {
60
+ fn panic(_info : &PanicInfo) -> ! {
43
61
loop {}
44
62
}
45
63
```
46
64
47
- ``` rust
65
+ ``` rust, ignore
48
66
// crate: app
49
67
50
68
#![no_std]
You can’t perform that action at this time.
0 commit comments