geo_svg/combine.rs
1use crate::{Svg, ToSvg};
2
3/// This trait let's you combine multiple things that can be converted to a SVG into one big
4/// compound SVG
5pub trait CombineToSVG {
6 fn combine_to_svg(&self) -> Option<Svg>;
7}
8
9impl<S: ToSvg> CombineToSVG for &[S] {
10 fn combine_to_svg(&self) -> Option<Svg> {
11 self.iter().map(|s| s.to_svg()).reduce(|a, b| a.and(b))
12 }
13}
14
15impl<S: ToSvg> CombineToSVG for Vec<S> {
16 fn combine_to_svg(&self) -> Option<Svg> {
17 self.iter().map(|s| s.to_svg()).reduce(|a, b| a.and(b))
18 }
19}