Skip to content

Instantly share code, notes, and snippets.

@karan1276
Created February 11, 2017 15:04
Show Gist options
  • Save karan1276/8844c4643ef621faaba6ed60f1a7ebd1 to your computer and use it in GitHub Desktop.
Save karan1276/8844c4643ef621faaba6ed60f1a7ebd1 to your computer and use it in GitHub Desktop.
enum ShadowSpecifiedValue {
None,
struct Shadow shdw
}
struct Shadow {
...
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Shadow, ()> {
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
ok(ShadowSpecifiedValue::None)
} else {
try!(Length::parse(input).map(ShadowSpecifiedValue::shdw::offset_x);
try!(Length::parse(input).map(ShadowSpecifiedValue::shdw::offset_y);
try!(Length::parse_nonnegative(input).map(ShadowSpecifiedValue::shdw::blur_radius);
try!(Length::parse(input).map(ShadowSpecifiedValue::shdw::spread_radius);
try!(CSSColor::parse(input).map(ShadowSpecifiedValue::shdw::color);
if input.try(|input| input.expect_ident_matching("inset")).is_ok() {
ShadowSpecifiedValue::shdw::inset = true;
} else{
ShadowSpecifiedValue::shdw::inset = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment