Skip to content

Commit d7cc62d

Browse files
author
=
committed
Use Utf16Writer in the panic hook
1 parent c48e55a commit d7cc62d

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

ctru-rs/src/applets/error.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,6 @@ impl PopUp {
9292
}
9393
}
9494

95-
struct ErrorConfWriter<'a> {
96-
error_conf: &'a mut errorConf,
97-
index: usize,
98-
}
99-
100-
impl std::fmt::Write for ErrorConfWriter<'_> {
101-
fn write_str(&mut self, s: &str) -> Result<(), std::fmt::Error> {
102-
let max = self.error_conf.Text.len() - 1;
103-
104-
for code_unit in s.encode_utf16() {
105-
if self.index == max {
106-
self.error_conf.Text[self.index] = 0;
107-
return Err(std::fmt::Error);
108-
} else {
109-
self.error_conf.Text[self.index] = code_unit;
110-
self.index += 1;
111-
}
112-
}
113-
114-
self.error_conf.Text[self.index] = 0;
115-
116-
Ok(())
117-
}
118-
}
119-
12095
pub(crate) fn set_panic_hook(call_old_hook: bool) {
12196
use crate::services::gfx::GFX_ACTIVE;
12297
use std::fmt::Write;
@@ -142,10 +117,7 @@ pub(crate) fn set_panic_hook(call_old_hook: bool) {
142117

143118
let error_conf = &mut *lock;
144119

145-
let mut writer = ErrorConfWriter {
146-
error_conf,
147-
index: 0,
148-
};
120+
let mut writer = Utf16Writer::new(&mut error_conf.Text);
149121

150122
let thread = std::thread::current();
151123

0 commit comments

Comments
 (0)