File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,30 @@ The `panic_handler` attribute can only be applied to a function with signature
1717Below is shown a ` panic_handler ` function that logs the panic message and then halts the
1818thread.
1919
20- ``` rust
20+ <!-- NOTE(ignore) `mdbook test` doesn't support `no_std` code -->
21+
22+ ``` rust, ignore
2123#![no_std]
2224
23- use core :: intrinsics ;
25+ use core::fmt::{self, Write} ;
2426use core::panic::PanicInfo;
2527
28+ struct Sink {
29+ // ..
30+ # _0: (),
31+ }
32+ #
33+ # impl Sink {
34+ # fn new() -> Sink { Sink { _0: () }}
35+ # }
36+ #
37+ # impl fmt::Write for Sink {
38+ # fn write_str(&mut self, _: &str) -> fmt::Result { Ok(()) }
39+ # }
40+
2641#[panic_handler]
2742fn panic(info: &PanicInfo) -> ! {
28- let mut sink = /* .. */ ;
43+ let mut sink = Sink::new() ;
2944
3045 // logs "panicked at '$reason', src/main.rs:27:4" to some `sink`
3146 let _ = writeln!(sink, "{}", info);
You can’t perform that action at this time.
0 commit comments