File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -597,6 +597,14 @@ impl Axis {
597597 self . domain = Some ( domain. to_vec ( ) ) ;
598598 self
599599 }
600+
601+ pub fn single_axis ( axis : Axis ) ->Vec < Option < Box < Axis > > > {
602+ vec ! [ Some ( Box :: new( axis) ) ]
603+ }
604+
605+ pub fn from_axes ( axes : Vec < Axis > ) -> Vec < Option < Box < Axis > > > {
606+ axes. into_iter ( ) . map ( |axis| Some ( Box :: new ( axis) ) ) . collect ( )
607+ }
600608}
601609
602610#[ derive( Serialize , Debug , Clone ) ]
@@ -2872,6 +2880,20 @@ mod tests {
28722880 assert_eq ! ( to_value( annotation) . unwrap( ) , expected) ;
28732881 }
28742882
2883+ #[ test]
2884+ fn test_single_axis_builder ( ) {
2885+ let single_axis = Axis :: single_axis ( Axis :: new ( ) ) ;
2886+ let expected = json ! ( [ { } ] ) ;
2887+ assert_eq ! ( to_value( single_axis) . unwrap( ) , expected) ;
2888+ }
2889+
2890+ #[ test]
2891+ fn test_axes_builder ( ) {
2892+ let axes = Axis :: from_axes ( vec ! [ Axis :: new( ) , Axis :: new( ) ] ) ;
2893+ let expected = json ! ( [ { } , { } ] ) ;
2894+ assert_eq ! ( to_value( axes) . unwrap( ) , expected) ;
2895+ }
2896+
28752897 #[ test]
28762898 #[ rustfmt:: skip]
28772899 fn test_serialize_click_mode ( ) {
You can’t perform that action at this time.
0 commit comments