@@ -161,6 +161,39 @@ impl Line<GridPlacement> {
161161 end : self . end . into_origin_zero_placement ( explicit_track_count) ,
162162 }
163163 }
164+
165+ /// Convert raw values of start, span, and end into a [`GridPlacement`].
166+ /// Zero is not a valid value for any of the values and is thus used to indicate unset
167+ /// Only 2 of the 3 values should be set. If all 3 are set then `span_value` is ignored.
168+ pub ( crate ) fn from_raw_parts ( start : i16 , span_value : u16 , end : i16 ) -> Self {
169+ match ( start, span_value, end) {
170+ ( 0 , 0 , 0 ) => auto ( ) ,
171+ ( start, 0 , 0 ) => Line { start : line ( start) , end : auto ( ) } ,
172+ ( 0 , 0 , end) => Line { start : auto ( ) , end : line ( end) } ,
173+ ( 0 , span_value, 0 ) => span ( span_value) ,
174+ ( start, span_value, 0 ) => Line { start : line ( start) , end : span ( span_value) } ,
175+ ( 0 , span_value, end) => Line { start : auto ( ) , end : line ( end) } ,
176+ ( start, _, end) => Line { start : line ( start) , end : line ( end) } ,
177+ }
178+ }
179+
180+ /// Convert raw values of start, span, and end into a [`GridPlacement`].
181+ /// Zero is not a valid value for any of the values and is thus used to indicate unset
182+ /// Only 2 of the 3 values should be set. If all 3 are set then `span_value` is ignored.
183+ pub ( crate ) fn into_raw_parts ( self ) -> ( i16 , u16 , i16 ) {
184+ use GenericGridPlacement :: * ;
185+ match ( self . start , self . end ) {
186+ ( Line ( start) , Line ( end) ) => ( start. as_i16 ( ) , 0 , end. as_i16 ( ) ) ,
187+ ( Line ( start) , Span ( span) ) => ( start. as_i16 ( ) , span, 0 ) ,
188+ ( Line ( start) , Auto ) => ( start. as_i16 ( ) , 1 , 0 ) ,
189+ ( Span ( span) , Line ( end) ) => ( 0 , span, end. as_i16 ( ) ) ,
190+ ( Span ( span) , Span ( _) ) => ( 0 , span, 0 ) ,
191+ ( Span ( span) , Auto ) => ( 0 , span, 0 ) ,
192+ ( Auto , Line ( end) ) => ( 0 , 1 , end. as_i16 ( ) ) ,
193+ ( Auto , Span ( span) ) => ( 0 , span, 0 ) ,
194+ ( Auto , Auto ) => ( 0 , 1 , 0 ) ,
195+ }
196+ }
164197}
165198
166199impl Line < OriginZeroGridPlacement > {
0 commit comments