@@ -88,7 +88,7 @@ impl<'de> Deserialize<'de> for RGBA {
8888 fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
8989 where D : Deserializer < ' de >
9090 {
91- let ( r, g, b, a) = try! ( Deserialize :: deserialize ( deserializer) ) ;
91+ let ( r, g, b, a) = Deserialize :: deserialize ( deserializer) ? ;
9292 Ok ( RGBA :: new ( r, g, b, a) )
9393 }
9494}
@@ -141,7 +141,7 @@ impl Color {
141141 ///
142142 /// FIXME(#2) Deprecated CSS2 System Colors are not supported yet.
143143 pub fn parse < ' i , ' t > ( input : & mut Parser < ' i , ' t > ) -> Result < Color , BasicParseError < ' i > > {
144- let token = try! ( input. next ( ) ) ;
144+ let token = input. next ( ) ? ;
145145 match token {
146146 Token :: Hash ( ref value) | Token :: IDHash ( ref value) => {
147147 Color :: parse_hash ( value. as_bytes ( ) )
@@ -162,26 +162,26 @@ impl Color {
162162 pub fn parse_hash ( value : & [ u8 ] ) -> Result < Self , ( ) > {
163163 match value. len ( ) {
164164 8 => Ok ( rgba (
165- try! ( from_hex ( value[ 0 ] ) ) * 16 + try! ( from_hex ( value[ 1 ] ) ) ,
166- try! ( from_hex ( value[ 2 ] ) ) * 16 + try! ( from_hex ( value[ 3 ] ) ) ,
167- try! ( from_hex ( value[ 4 ] ) ) * 16 + try! ( from_hex ( value[ 5 ] ) ) ,
168- try! ( from_hex ( value[ 6 ] ) ) * 16 + try! ( from_hex ( value[ 7 ] ) ) ) ,
165+ from_hex ( value[ 0 ] ) ? * 16 + from_hex ( value[ 1 ] ) ? ,
166+ from_hex ( value[ 2 ] ) ? * 16 + from_hex ( value[ 3 ] ) ? ,
167+ from_hex ( value[ 4 ] ) ? * 16 + from_hex ( value[ 5 ] ) ? ,
168+ from_hex ( value[ 6 ] ) ? * 16 + from_hex ( value[ 7 ] ) ? ) ,
169169 ) ,
170170 6 => Ok ( rgb (
171- try! ( from_hex ( value[ 0 ] ) ) * 16 + try! ( from_hex ( value[ 1 ] ) ) ,
172- try! ( from_hex ( value[ 2 ] ) ) * 16 + try! ( from_hex ( value[ 3 ] ) ) ,
173- try! ( from_hex ( value[ 4 ] ) ) * 16 + try! ( from_hex ( value[ 5 ] ) ) ) ,
171+ from_hex ( value[ 0 ] ) ? * 16 + from_hex ( value[ 1 ] ) ? ,
172+ from_hex ( value[ 2 ] ) ? * 16 + from_hex ( value[ 3 ] ) ? ,
173+ from_hex ( value[ 4 ] ) ? * 16 + from_hex ( value[ 5 ] ) ? ) ,
174174 ) ,
175175 4 => Ok ( rgba (
176- try! ( from_hex ( value[ 0 ] ) ) * 17 ,
177- try! ( from_hex ( value[ 1 ] ) ) * 17 ,
178- try! ( from_hex ( value[ 2 ] ) ) * 17 ,
179- try! ( from_hex ( value[ 3 ] ) ) * 17 ) ,
176+ from_hex ( value[ 0 ] ) ? * 17 ,
177+ from_hex ( value[ 1 ] ) ? * 17 ,
178+ from_hex ( value[ 2 ] ) ? * 17 ,
179+ from_hex ( value[ 3 ] ) ? * 17 ) ,
180180 ) ,
181181 3 => Ok ( rgb (
182- try! ( from_hex ( value[ 0 ] ) ) * 17 ,
183- try! ( from_hex ( value[ 1 ] ) ) * 17 ,
184- try! ( from_hex ( value[ 2 ] ) ) * 17 ) ,
182+ from_hex ( value[ 0 ] ) ? * 17 ,
183+ from_hex ( value[ 1 ] ) ? * 17 ,
184+ from_hex ( value[ 2 ] ) ? * 17 ) ,
185185 ) ,
186186 _ => Err ( ( ) )
187187 }
@@ -420,14 +420,14 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
420420
421421 let alpha = if !arguments. is_exhausted ( ) {
422422 if uses_commas {
423- try! ( arguments. expect_comma ( ) ) ;
423+ arguments. expect_comma ( ) ? ;
424424 } else {
425- match try! ( arguments. next ( ) ) {
425+ match arguments. next ( ) ? {
426426 Token :: Delim ( '/' ) => { } ,
427427 t => return Err ( BasicParseError :: UnexpectedToken ( t) ) ,
428428 } ;
429429 } ;
430- let token = try! ( arguments. next ( ) ) ;
430+ let token = arguments. next ( ) ? ;
431431 match token {
432432 Token :: Number { value : v, .. } => {
433433 clamp_unit_f32 ( v)
@@ -443,7 +443,7 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
443443 255
444444 } ;
445445
446- try! ( arguments. expect_exhausted ( ) ) ;
446+ arguments. expect_exhausted ( ) ? ;
447447 Ok ( rgba ( red, green, blue, alpha) )
448448}
449449
@@ -457,36 +457,36 @@ fn parse_rgb_components_rgb<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
457457
458458 // Either integers or percentages, but all the same type.
459459 // https://drafts.csswg.org/css-color/#rgb-functions
460- match try! ( arguments. next ( ) ) {
460+ match arguments. next ( ) ? {
461461 Token :: Number { value : v, .. } => {
462462 red = clamp_floor_256_f32 ( v) ;
463- green = clamp_floor_256_f32 ( match try! ( arguments. next ( ) ) {
463+ green = clamp_floor_256_f32 ( match arguments. next ( ) ? {
464464 Token :: Number { value : v, .. } => v,
465465 Token :: Comma => {
466466 uses_commas = true ;
467- try! ( arguments. expect_number ( ) )
467+ arguments. expect_number ( ) ?
468468 }
469469 t => return Err ( BasicParseError :: UnexpectedToken ( t) )
470470 } ) ;
471471 if uses_commas {
472- try! ( arguments. expect_comma ( ) ) ;
472+ arguments. expect_comma ( ) ? ;
473473 }
474- blue = clamp_floor_256_f32 ( try! ( arguments. expect_number ( ) ) ) ;
474+ blue = clamp_floor_256_f32 ( arguments. expect_number ( ) ? ) ;
475475 }
476476 Token :: Percentage { unit_value, .. } => {
477477 red = clamp_unit_f32 ( unit_value) ;
478- green = clamp_unit_f32 ( match try! ( arguments. next ( ) ) {
478+ green = clamp_unit_f32 ( match arguments. next ( ) ? {
479479 Token :: Percentage { unit_value, .. } => unit_value,
480480 Token :: Comma => {
481481 uses_commas = true ;
482- try! ( arguments. expect_percentage ( ) )
482+ arguments. expect_percentage ( ) ?
483483 }
484484 t => return Err ( BasicParseError :: UnexpectedToken ( t) )
485485 } ) ;
486486 if uses_commas {
487- try! ( arguments. expect_comma ( ) ) ;
487+ arguments. expect_comma ( ) ? ;
488488 }
489- blue = clamp_unit_f32 ( try! ( arguments. expect_percentage ( ) ) ) ;
489+ blue = clamp_unit_f32 ( arguments. expect_percentage ( ) ? ) ;
490490 }
491491 t => return Err ( BasicParseError :: UnexpectedToken ( t) )
492492 } ;
@@ -498,7 +498,7 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
498498 let mut uses_commas = false ;
499499 // Hue given as an angle
500500 // https://drafts.csswg.org/css-values/#angles
501- let token = try! ( arguments. next ( ) ) ;
501+ let token = arguments. next ( ) ? ;
502502 let hue_degrees = match token {
503503 Token :: Number { value : v, .. } => Ok ( v) ,
504504 Token :: Dimension { value : v, ref unit, .. } => {
@@ -512,28 +512,28 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
512512 }
513513 t => return Err ( BasicParseError :: UnexpectedToken ( t) )
514514 } ;
515- let hue_degrees = try! ( hue_degrees. map_err ( |( ) | BasicParseError :: UnexpectedToken ( token) ) ) ;
515+ let hue_degrees = hue_degrees. map_err ( |( ) | BasicParseError :: UnexpectedToken ( token) ) ? ;
516516 // Subtract an integer before rounding, to avoid some rounding errors:
517517 let hue_normalized_degrees = hue_degrees - 360. * ( hue_degrees / 360. ) . floor ( ) ;
518518 let hue = hue_normalized_degrees / 360. ;
519519
520520 // Saturation and lightness are clamped to 0% ... 100%
521521 // https://drafts.csswg.org/css-color/#the-hsl-notation
522- let saturation = match try! ( arguments. next ( ) ) {
522+ let saturation = match arguments. next ( ) ? {
523523 Token :: Percentage { unit_value, .. } => unit_value,
524524 Token :: Comma => {
525525 uses_commas = true ;
526- try! ( arguments. expect_percentage ( ) )
526+ arguments. expect_percentage ( ) ?
527527 }
528528 t => return Err ( BasicParseError :: UnexpectedToken ( t) )
529529 } ;
530530 let saturation = saturation. max ( 0. ) . min ( 1. ) ;
531531
532532 if uses_commas {
533- try! ( arguments. expect_comma ( ) ) ;
533+ arguments. expect_comma ( ) ? ;
534534 }
535535
536- let lightness = try! ( arguments. expect_percentage ( ) ) ;
536+ let lightness = arguments. expect_percentage ( ) ? ;
537537 let lightness = lightness. max ( 0. ) . min ( 1. ) ;
538538
539539 // https://drafts.csswg.org/css-color/#hsl-color
0 commit comments