color-parser 0.1.0

Css color level3 parser
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use nom::{
    error::{Error, ErrorKind},
    Err,
};

pub type ErrorMessage = Err<Error<&'static str>>;

pub fn nom_error<T>(kind: ErrorKind, input: &'static str) -> Result<T, Err<Error<&'static str>>> {
    Err(Err::Error(Error::new(input, kind)))
}

pub fn clamp(value: f32) -> f32 {
    value.max(0.).min(1.)
}