@@ -893,113 +893,11 @@ pub enum Reference {
893893 Paper ,
894894}
895895
896- #[ derive( Clone , Debug , PartialEq , Eq ) ]
897- pub enum XAxisId {
898- X1 ,
899- X2 ,
900- X3 ,
901- X4 ,
902- Custom ( String ) ,
903- }
904-
905- impl XAxisId {
906- fn as_str ( & self ) -> & str {
907- match self {
908- Self :: X1 => "x" ,
909- Self :: X2 => "x2" ,
910- Self :: X3 => "x3" ,
911- Self :: X4 => "x4" ,
912- Self :: Custom ( value) => value. as_str ( ) ,
913- }
914- }
915- }
916-
917- impl Serialize for XAxisId {
918- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
919- where
920- S : Serializer ,
921- {
922- serializer. serialize_str ( self . as_str ( ) )
923- }
924- }
925-
926- impl From < & str > for XAxisId {
927- fn from ( value : & str ) -> Self {
928- match value {
929- "x" | "x1" => Self :: X1 ,
930- "x2" => Self :: X2 ,
931- "x3" => Self :: X3 ,
932- "x4" => Self :: X4 ,
933- _ => Self :: Custom ( value. to_string ( ) ) ,
934- }
935- }
936- }
937-
938- impl From < String > for XAxisId {
939- fn from ( value : String ) -> Self {
940- Self :: from ( value. as_str ( ) )
941- }
942- }
943-
944- impl From < XAxisId > for String {
945- fn from ( value : XAxisId ) -> Self {
946- value. as_str ( ) . to_string ( )
947- }
948- }
949-
950- #[ derive( Clone , Debug , PartialEq , Eq ) ]
951- pub enum YAxisId {
952- Y1 ,
953- Y2 ,
954- Y3 ,
955- Y4 ,
956- Custom ( String ) ,
957- }
958-
959- impl YAxisId {
960- fn as_str ( & self ) -> & str {
961- match self {
962- Self :: Y1 => "y" ,
963- Self :: Y2 => "y2" ,
964- Self :: Y3 => "y3" ,
965- Self :: Y4 => "y4" ,
966- Self :: Custom ( value) => value. as_str ( ) ,
967- }
968- }
969- }
970-
971- impl Serialize for YAxisId {
972- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
973- where
974- S : Serializer ,
975- {
976- serializer. serialize_str ( self . as_str ( ) )
977- }
978- }
979-
980- impl From < & str > for YAxisId {
981- fn from ( value : & str ) -> Self {
982- match value {
983- "y" | "y1" => Self :: Y1 ,
984- "y2" => Self :: Y2 ,
985- "y3" => Self :: Y3 ,
986- "y4" => Self :: Y4 ,
987- _ => Self :: Custom ( value. to_string ( ) ) ,
988- }
989- }
990- }
991-
992- impl From < String > for YAxisId {
993- fn from ( value : String ) -> Self {
994- Self :: from ( value. as_str ( ) )
995- }
996- }
896+ /// Axis id for a 2D cartesian x axis.
897+ pub type XAxisId = String ;
997898
998- impl From < YAxisId > for String {
999- fn from ( value : YAxisId ) -> Self {
1000- value. as_str ( ) . to_string ( )
1001- }
1002- }
899+ /// Axis id for a 2D cartesian y axis.
900+ pub type YAxisId = String ;
1003901
1004902#[ derive( Serialize , Clone , Debug ) ]
1005903pub struct Pad {
@@ -1909,18 +1807,10 @@ mod tests {
19091807
19101808 #[ test]
19111809 fn serialize_axis_id ( ) {
1912- assert_eq ! ( to_value( XAxisId :: X1 ) . unwrap( ) , json!( "x" ) ) ;
1913- assert_eq ! ( to_value( XAxisId :: X3 ) . unwrap( ) , json!( "x3" ) ) ;
1914- assert_eq ! (
1915- to_value( XAxisId :: Custom ( "x7" . to_string( ) ) ) . unwrap( ) ,
1916- json!( "x7" )
1917- ) ;
1918- assert_eq ! ( to_value( YAxisId :: Y1 ) . unwrap( ) , json!( "y" ) ) ;
1919- assert_eq ! ( to_value( YAxisId :: Y4 ) . unwrap( ) , json!( "y4" ) ) ;
1920- assert_eq ! (
1921- to_value( YAxisId :: Custom ( "y8" . to_string( ) ) ) . unwrap( ) ,
1922- json!( "y8" )
1923- ) ;
1810+ assert_eq ! ( to_value( XAxisId :: from( "x" ) ) . unwrap( ) , json!( "x" ) ) ;
1811+ assert_eq ! ( to_value( XAxisId :: from( "x3" ) ) . unwrap( ) , json!( "x3" ) ) ;
1812+ assert_eq ! ( to_value( YAxisId :: from( "y" ) ) . unwrap( ) , json!( "y" ) ) ;
1813+ assert_eq ! ( to_value( YAxisId :: from( "y8" ) ) . unwrap( ) , json!( "y8" ) ) ;
19241814 }
19251815
19261816 #[ test]
0 commit comments