1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2026-05-18 09:51:14 +02:00

Avoid nested function definition

This commit is contained in:
Remo Senekowitsch
2026-04-25 14:04:29 +02:00
parent c658a997f3
commit e0334f79fe
+11 -10
View File
@@ -233,16 +233,6 @@ impl<'a> ListState<'a> {
)?;
next_ln(stdout)?;
fn hotkey(writer: &mut MaxLenWriter, hotkey: &[u8]) -> io::Result<()> {
writer
.stdout
.queue(SetForegroundColor(Color::Yellow))?
.queue(SetAttribute(Attribute::Bold))?;
writer.write_ascii(hotkey)?;
writer.stdout.queue(ResetColor)?;
Ok(())
}
let mut writer = MaxLenWriter::new(stdout, self.term_width as usize);
if self.message.is_empty() {
// Help footer message
@@ -446,3 +436,14 @@ impl<'a> ListState<'a> {
Ok(true)
}
}
/// Draw an emphasized hotkey in the list footer.
fn hotkey(writer: &mut MaxLenWriter, hotkey: &[u8]) -> io::Result<()> {
writer
.stdout
.queue(SetForegroundColor(Color::Yellow))?
.queue(SetAttribute(Attribute::Bold))?;
writer.write_ascii(hotkey)?;
writer.stdout.queue(ResetColor)?;
Ok(())
}