From 02481656966b0a8dfc95cf3c22bcc049660ff7d4 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sat, 26 Dec 2020 17:48:38 +0000 Subject: Move Rust exercises in a subdirectory --- high-scores/src/lib.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 high-scores/src/lib.rs (limited to 'high-scores/src') diff --git a/high-scores/src/lib.rs b/high-scores/src/lib.rs deleted file mode 100644 index a7e6c3d..0000000 --- a/high-scores/src/lib.rs +++ /dev/null @@ -1,29 +0,0 @@ -#[derive(Debug)] -pub struct HighScores<'a> { - scores: &'a [u32] -} - -impl<'a> HighScores<'a> { - pub fn new(scores: &'a [u32]) -> Self { - HighScores{ scores } - } - - pub fn scores(&self) -> &[u32] { - self.scores - } - - pub fn latest(&self) -> Option { - self.scores.last().copied() - } - - pub fn personal_best(&self) -> Option { - self.scores.iter().max().copied() - } - - pub fn personal_top_three(&self) -> Vec { - let mut top3 = self.scores.to_vec(); - top3.sort_unstable_by(|a,b| b.cmp(a)); - top3.truncate(3); - top3 - } -} -- cgit v1.2.3