Commit 28ea3cb7 authored by Federico Mena Quintero's avatar Federico Mena Quintero
Browse files

parses_stroke_dasharray() - Don't use discriminant checks; use PartialEq comparisons

The code is prettier this way, and doesn't require Rust 1.21.
parent 950efcaa
Pipeline #4067 passed with stages
in 13 minutes and 8 seconds
......@@ -311,7 +311,7 @@ pub struct RsvgStrokeDasharray {
pub dashes: *mut RsvgLength
}
#[derive(Debug)]
#[derive(Debug, PartialEq)]
enum StrokeDasharray {
None,
Inherit,
......@@ -542,12 +542,10 @@ mod tests {
#[test]
fn parses_stroke_dasharray() {
use std::mem::discriminant;
// https://doc.rust-lang.org/std/mem/fn.discriminant.html
assert_eq!(discriminant(&parse_stroke_dash_array("none").unwrap()), discriminant(&StrokeDasharray::None));
assert_eq!(discriminant(&parse_stroke_dash_array("inherit").unwrap()), discriminant(&StrokeDasharray::Inherit));
assert_eq!(discriminant(&parse_stroke_dash_array("10, 5").unwrap()), discriminant(&StrokeDasharray::Dasharray(parse_dash_array("10, 5").unwrap())));
assert_eq!(parse_stroke_dash_array("none").unwrap(), StrokeDasharray::None);
assert_eq!(parse_stroke_dash_array("inherit").unwrap(), StrokeDasharray::Inherit);
assert_eq!(parse_stroke_dash_array("10, 5").unwrap(),
StrokeDasharray::Dasharray(parse_dash_array("10, 5").unwrap()));
assert!(parse_stroke_dash_array("").is_err());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment