#[repr(u8)]pub enum Sign {
Plus = 43,
Minus = 45,
}
Expand description
Sign token
Represents a sign character in the SVG path. The following characters are considered signs following the v1.1 SVG Path specification:
- Plus (U+002B)
- Minus (U+002D)
§Example
use svg_path_cst::{
svg_path_cst, SVGPathCSTNode, SVGPathCommand, SVGPathSegment, Sign,
};
let cst = svg_path_cst(b"M+10-10").unwrap();
assert_eq!(
cst,
vec![
SVGPathCSTNode::Segment(SVGPathSegment {
command: &SVGPathCommand::MovetoUpper,
args: vec![10.0, -10.0],
cst: vec![
SVGPathCSTNode::Command(&SVGPathCommand::MovetoUpper),
SVGPathCSTNode::Sign{
sign: &Sign::Plus,
start: 1,
},
SVGPathCSTNode::Number{
raw_number: "10".to_string(),
value: 10.0,
start: 2,
end: 4,
},
SVGPathCSTNode::Sign{
sign: &Sign::Minus,
start: 4,
},
SVGPathCSTNode::Number{
raw_number: "10".to_string(),
value: 10.0,
start: 5,
end: 7,
},
],
start: 0,
end: 7,
chained: false,
chain_start: 0,
chain_end: 7,
}),
]
);
for node in &cst {
match node {
SVGPathCSTNode::Sign{sign, ..} => {
match sign {
Sign::Plus => println!("+"),
Sign::Minus => println!("-"),
}
}
_ => (),
}
}
// or just use `as u8 as char`
for node in cst {
match node {
SVGPathCSTNode::Sign{sign, ..} => {
println!("{}", *sign as u8 as char);
}
_ => (),
}
}
Variants§
Implementations§
Trait Implementations§
impl Copy for Sign
impl StructuralPartialEq for Sign
Auto Trait Implementations§
impl Freeze for Sign
impl RefUnwindSafe for Sign
impl Send for Sign
impl Sync for Sign
impl Unpin for Sign
impl UnwindSafe for Sign
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more