11//! Geometric primitives useful for layout
22
3- use crate :: style:: { Dimension , FlexDirection } ;
3+ use crate :: style:: Dimension ;
44use crate :: sys:: f32_max;
55use core:: ops:: Add ;
66
7+ #[ cfg( feature = "flexbox" ) ]
8+ use crate :: style:: FlexDirection ;
9+
710#[ cfg( feature = "grid" ) ]
811use crate :: axis:: AbstractAxis ;
912
@@ -61,6 +64,7 @@ impl<T> Rect<T> {
6164 /// When applied to the left and right sides, the width is used
6265 /// as the second parameter of `f`.
6366 /// When applied to the top or bottom sides, the height is used instead.
67+ #[ cfg( feature = "flexbox" ) ]
6468 pub ( crate ) fn zip_size < R , F , U > ( self , size : Size < U > , f : F ) -> Rect < R >
6569 where
6670 F : Fn ( T , U ) -> R ,
@@ -134,6 +138,7 @@ where
134138 ///
135139 /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::horizontal`].
136140 /// Otherwise, this is [`Rect::vertical`].
141+ #[ cfg( feature = "flexbox" ) ]
137142 pub ( crate ) fn main_axis_sum ( & self , direction : FlexDirection ) -> U {
138143 if direction. is_row ( ) {
139144 self . horizontal_axis_sum ( )
@@ -146,6 +151,7 @@ where
146151 ///
147152 /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::vertical`].
148153 /// Otherwise, this is [`Rect::horizontal`].
154+ #[ cfg( feature = "flexbox" ) ]
149155 pub ( crate ) fn cross_axis_sum ( & self , direction : FlexDirection ) -> U {
150156 if direction. is_row ( ) {
151157 self . vertical_axis_sum ( )
@@ -160,6 +166,7 @@ where
160166 T : Copy + Clone ,
161167{
162168 /// The `start` or `top` value of the [`Rect`], from the perspective of the main layout axis
169+ #[ cfg( feature = "flexbox" ) ]
163170 pub ( crate ) fn main_start ( & self , direction : FlexDirection ) -> T {
164171 if direction. is_row ( ) {
165172 self . left
@@ -169,6 +176,7 @@ where
169176 }
170177
171178 /// The `end` or `bottom` value of the [`Rect`], from the perspective of the main layout axis
179+ #[ cfg( feature = "flexbox" ) ]
172180 pub ( crate ) fn main_end ( & self , direction : FlexDirection ) -> T {
173181 if direction. is_row ( ) {
174182 self . right
@@ -178,6 +186,7 @@ where
178186 }
179187
180188 /// The `start` or `top` value of the [`Rect`], from the perspective of the cross layout axis
189+ #[ cfg( feature = "flexbox" ) ]
181190 pub ( crate ) fn cross_start ( & self , direction : FlexDirection ) -> T {
182191 if direction. is_row ( ) {
183192 self . top
@@ -187,6 +196,7 @@ where
187196 }
188197
189198 /// The `end` or `bottom` value of the [`Rect`], from the perspective of the main layout axis
199+ #[ cfg( feature = "flexbox" ) ]
190200 pub ( crate ) fn cross_end ( & self , direction : FlexDirection ) -> T {
191201 if direction. is_row ( ) {
192202 self . bottom
@@ -301,6 +311,7 @@ impl<T> Size<T> {
301311 /// Sets the extent of the main layout axis
302312 ///
303313 /// Whether this is the width or height depends on the `direction` provided
314+ #[ cfg( feature = "flexbox" ) ]
304315 pub ( crate ) fn set_main ( & mut self , direction : FlexDirection , value : T ) {
305316 if direction. is_row ( ) {
306317 self . width = value
@@ -312,6 +323,7 @@ impl<T> Size<T> {
312323 /// Sets the extent of the cross layout axis
313324 ///
314325 /// Whether this is the width or height depends on the `direction` provided
326+ #[ cfg( feature = "flexbox" ) ]
315327 pub ( crate ) fn set_cross ( & mut self , direction : FlexDirection , value : T ) {
316328 if direction. is_row ( ) {
317329 self . height = value
@@ -324,6 +336,7 @@ impl<T> Size<T> {
324336 ///
325337 /// Whether this is the width or height depends on the `direction` provided
326338 #[ allow( dead_code) ]
339+ #[ cfg( feature = "flexbox" ) ]
327340 pub ( crate ) fn with_main ( self , direction : FlexDirection , value : T ) -> Self {
328341 let mut new = self ;
329342 if direction. is_row ( ) {
@@ -337,6 +350,7 @@ impl<T> Size<T> {
337350 /// Creates a new value of type Self with the cross axis set to value provided
338351 ///
339352 /// Whether this is the width or height depends on the `direction` provided
353+ #[ cfg( feature = "flexbox" ) ]
340354 pub ( crate ) fn with_cross ( self , direction : FlexDirection , value : T ) -> Self {
341355 let mut new = self ;
342356 if direction. is_row ( ) {
@@ -350,6 +364,7 @@ impl<T> Size<T> {
350364 /// Gets the extent of the main layout axis
351365 ///
352366 /// Whether this is the width or height depends on the `direction` provided
367+ #[ cfg( feature = "flexbox" ) ]
353368 pub ( crate ) fn main ( self , direction : FlexDirection ) -> T {
354369 if direction. is_row ( ) {
355370 self . width
@@ -361,6 +376,7 @@ impl<T> Size<T> {
361376 /// Gets the extent of the cross layout axis
362377 ///
363378 /// Whether this is the width or height depends on the `direction` provided
379+ #[ cfg( feature = "flexbox" ) ]
364380 pub ( crate ) fn cross ( self , direction : FlexDirection ) -> T {
365381 if direction. is_row ( ) {
366382 self . height
0 commit comments