master > master: code-rust - util min durch macro ersetzt

This commit is contained in:
RD
2022-04-14 11:54:49 +02:00
parent 37f05d1ff0
commit 07b214bc24
2 changed files with 21 additions and 9 deletions

View File

@@ -25,11 +25,22 @@ pub fn construct_regex(pattern: &str) -> Regex {
// METHODS values
// ----------------------------------------------------------------
pub fn min<T>(x: T, y: T) -> T
where T: PartialOrd
{
return if y < x { y } else { x };
#[macro_export]
macro_rules! value_min{
($value:expr $(,)?)=>{ $value };
($value:expr $(, $values:expr)+ $(,)?)=>{
{
let x = $crate::value_min!($( $values )+);
if $value < x {
$value
} else {
x
}
}
};
}
#[allow(unused_imports)]
pub(crate) use value_min;
// ----------------------------------------------------------------
// METHODS Vectors