computer: big refactor

This commit is contained in:
nym21
2025-12-03 19:33:08 +01:00
parent fcc74ba212
commit d27cc02e8c
34 changed files with 2343 additions and 7340 deletions

View File

@@ -1,5 +1,25 @@
use std::ops::{Add, Div};
/// Extension trait for Option to provide shorter unwrap methods
pub trait OptionExt<T> {
/// Shorthand for `.as_ref().unwrap()`
fn u(&self) -> &T;
/// Shorthand for `.as_mut().unwrap()`
fn um(&mut self) -> &mut T;
}
impl<T> OptionExt<T> for Option<T> {
#[inline]
fn u(&self) -> &T {
self.as_ref().unwrap()
}
#[inline]
fn um(&mut self) -> &mut T {
self.as_mut().unwrap()
}
}
pub fn get_percentile<T>(sorted: &[T], percentile: f64) -> T
where
T: Clone + Div<usize, Output = T> + Add<T, Output = T>,