1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::{error, fmt};
pub fn check_debug_marker_color(color: [f32; 4]) -> Result<(), CheckColorError> {
if color.iter().any(|x| !(0f32..=1f32).contains(x)) {
return Err(CheckColorError);
}
Ok(())
}
#[derive(Debug, Copy, Clone)]
pub struct CheckColorError;
impl error::Error for CheckColorError {}
impl fmt::Display for CheckColorError {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(
fmt,
"{}",
match *self {
CheckColorError => "color parameter does contains values out of 0.0 to 1.0 range",
}
)
}
}