File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,7 +106,15 @@ impl<const N: usize> TryFrom<[Point; N]> for Points {
106106 type Error = InputError ;
107107
108108 fn try_from ( points : [ Point ; N ] ) -> Result < Self , Self :: Error > {
109- Self :: try_from ( Vec :: from ( points) )
109+ if N < MIN_POINTS {
110+ return Err ( InputError :: TooFewPoints {
111+ len : N ,
112+ min_required : MIN_POINTS ,
113+ } ) ;
114+ }
115+ Ok ( Self {
116+ points : Arc :: from ( points) ,
117+ } )
110118 }
111119}
112120
Original file line number Diff line number Diff line change @@ -43,6 +43,20 @@ fn points_require_at_least_two_values() {
4343 ) ;
4444}
4545
46+ #[ test]
47+ fn points_array_construction_rejects_short_arrays ( ) {
48+ let points = [ Point :: try_new ( 0.0 , 0.0 ) . unwrap ( ) ] ;
49+ let error = Points :: try_from ( points) . expect_err ( "must reject short arrays" ) ;
50+
51+ assert_eq ! (
52+ error,
53+ InputError :: TooFewPoints {
54+ len: 1 ,
55+ min_required: 2 ,
56+ }
57+ ) ;
58+ }
59+
4660#[ test]
4761fn family_validation_checks_min_points_and_domain ( ) {
4862 let points = Points :: try_from ( [
You can’t perform that action at this time.
0 commit comments