33 Zeilen
778 B
Rust
33 Zeilen
778 B
Rust
use super::Kartesian;
|
|
use num::*;
|
|
|
|
pub trait MaximumFromMap<T: Integer> {
|
|
fn maximum<U>(map: &Vec<Vec<U>>) -> Kartesian<T>;
|
|
}
|
|
|
|
macro_rules! impl_maximum {
|
|
($type:ident) => {
|
|
impl MaximumFromMap<$type> for Kartesian<$type> {
|
|
fn maximum<U>(map: &Vec<Vec<U>>) -> Kartesian<$type> {
|
|
Kartesian {
|
|
x: map.len() as $type,
|
|
y: map[0].len() as $type,
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
impl_maximum!(u8);
|
|
impl_maximum!(u16);
|
|
impl_maximum!(u32);
|
|
impl_maximum!(u64);
|
|
impl_maximum!(u128);
|
|
|
|
impl MaximumFromMap<usize> for Kartesian<usize> {
|
|
fn maximum<U>(map: &Vec<Vec<U>>) -> Kartesian<usize> {
|
|
Kartesian {
|
|
x: map.len(),
|
|
y: map[0].len(),
|
|
}
|
|
}
|
|
}
|