* simplify footer

* improve: &T vs. &mut T

* remove header

* adjust table space

* update README
This commit is contained in:
Jens K.
2024-12-23 14:24:15 +01:00
committed by GitHub
parent 98ee2bc16b
commit d86f8905f2
7 changed files with 71 additions and 109 deletions

View File

@@ -207,7 +207,7 @@ impl<T> Clock<T> {
self.update_mode();
}
pub fn get_mode(&mut self) -> &Mode {
pub fn get_mode(&self) -> &Mode {
&self.mode
}
@@ -215,7 +215,7 @@ impl<T> Clock<T> {
self.mode == Mode::Tick
}
pub fn is_edit_mode(&mut self) -> bool {
pub fn is_edit_mode(&self) -> bool {
matches!(self.mode, Mode::Editable(_, _))
}
@@ -301,7 +301,7 @@ impl<T> Clock<T> {
(self.current_value.subsec_millis() / 100) as u64
}
pub fn is_done(&mut self) -> bool {
pub fn is_done(&self) -> bool {
self.mode == Mode::Done
}
@@ -375,12 +375,12 @@ impl Clock<Countdown> {
pub fn tick(&mut self) {
if self.mode == Mode::Tick {
self.current_value = self.current_value.saturating_sub(self.tick_value);
self.check_done();
self.set_done();
self.update_format();
}
}
pub fn check_done(&mut self) {
pub fn set_done(&mut self) {
if self.current_value.is_zero() {
self.mode = Mode::Done;
}
@@ -447,12 +447,12 @@ impl Clock<Timer> {
pub fn tick(&mut self) {
if self.mode == Mode::Tick {
self.current_value = self.current_value.saturating_add(self.tick_value);
self.check_done();
self.set_done();
self.update_format();
}
}
fn check_done(&mut self) {
fn set_done(&mut self) {
if self.current_value >= MAX_DURATION {
self.mode = Mode::Done;
}