@@ -191,8 +191,11 @@ impl BezPath {
191
191
// TODO: expose as pub method? Maybe should be a trait so slice.segments() works?
192
192
fn segments_of_slice < ' a > ( slice : & ' a [ PathEl ] ) -> BezPathSegs < ' a > {
193
193
let first = match slice. get ( 0 ) {
194
- Some ( PathEl :: MoveTo ( ref p) ) => * p,
195
- Some ( _) => panic ! ( "First element has to be a PathEl::Moveto!" ) ,
194
+ Some ( PathEl :: MoveTo ( p) ) => * p,
195
+ Some ( PathEl :: LineTo ( p) ) => * p,
196
+ Some ( PathEl :: QuadTo ( _, p2) ) => * p2,
197
+ Some ( PathEl :: CurveTo ( _, _, p3) ) => * p3,
198
+ Some ( PathEl :: ClosePath ) => panic ! ( "Can't start a segment on a ClosePath" ) ,
196
199
None => Default :: default ( ) ,
197
200
} ;
198
201
@@ -747,6 +750,10 @@ impl Shape for BezPath {
747
750
}
748
751
}
749
752
753
+ /// Implements [`Shape`] for a slice of [`PathEl`], provided that the first element of the slice is
754
+ /// not a `PathEl::ClosePath`. If it is, several of these functions will panic.
755
+ ///
756
+ /// If the slice starts with `LineTo`, `QuadTo`, or `CurveTo`, it will be treated as a `MoveTo`.
750
757
impl < ' a > Shape for & ' a [ PathEl ] {
751
758
type BezPathIter = std:: iter:: Cloned < std:: slice:: Iter < ' a , PathEl > > ;
752
759
0 commit comments