1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
use crate::{Path, PolyType, Polygon, Polygons, Vertice}; pub struct PolygonsDebug<'a>(pub &'a Polygons); pub struct PolygonDebug<'a>(pub &'a Polygon); pub struct PathDebug<'a>(pub &'a Path); pub struct PathsDebug<'a>(pub &'a [Path]); pub struct PolyTypeDebug<'a>(pub &'a PolyType); pub struct VerticesDebug<'a>(pub &'a [Vertice]); pub struct VerticeDebug<'a>(pub &'a Vertice); impl<'a> std::fmt::Debug for PolygonsDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_list() .entries( self.0 .polygons() .iter() .map(|polygon| PolygonDebug(polygon)), ) .finish() } } impl<'a> std::fmt::Debug for PolygonDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_struct("Polygon") .field("paths", &PathsDebug(self.0.paths())) .field("type", &PolyTypeDebug(&self.0.type_)) .finish() } } impl<'a> std::fmt::Debug for PathDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_struct("Path") .field("vertices", &VerticesDebug(self.0.vertices())) .field("closed", &self.0.closed) .finish() } } impl<'a> std::fmt::Debug for VerticesDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_list() .entries(self.0.iter().map(|vertice| VerticeDebug(vertice))) .finish() } } impl<'a> std::fmt::Debug for VerticeDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_list() .entry(&self.0[0]) .entry(&self.0[1]) .finish() } } impl<'a> std::fmt::Debug for PathsDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_list() .entries(self.0.iter().map(|path| PathDebug(path))) .finish() } } impl<'a> std::fmt::Debug for PolyTypeDebug<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.write_str(match *self.0 { crate::clipper::PolyType_ptSubject => "ptSubject", crate::clipper::PolyType_ptClip => "ptClip", _ => "invalid type", }) } }