mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-17 15:32:18 -08:00
rust version of word
This commit is contained in:
19
96_Word/rust/src/progress.rs
Normal file
19
96_Word/rust/src/progress.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
pub struct Progress {
|
||||
chars: [char; 5],
|
||||
}
|
||||
|
||||
impl Progress {
|
||||
pub fn new() -> Self {
|
||||
Progress { chars: ['-'; 5] }
|
||||
}
|
||||
|
||||
pub fn set_char_at(&mut self, c: char, i: usize) {
|
||||
self.chars[i] = c;
|
||||
}
|
||||
|
||||
pub fn print(&self) {
|
||||
for c in self.chars {
|
||||
print!("{}", c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user