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