gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1112HTML 1039Markdown 12TOML 94628 Definitions

Fix building with grid feature disabled

6c62bd8db839bde826e6edb3ff07168ec4183be3 · by Nico Burns · (3 years ago) · parent 54ed355d4 · browse the tree at this commit

Semantic delta

No definition changed: this change is text, documentation or data.

5 files · +17 −9

diff --git a/src/axis.rs b/src/axis.rs
index 153924911..eb2b76bb5 100644
--- a/src/axis.rs
+++ b/src/axis.rs
@@ -75,6 +75,7 @@ pub(crate) struct InBothAbsAxis<T> {
 }
 
 impl<T: Copy> InBothAbsAxis<T> {
+    #[cfg(feature = "grid")]
     /// Get the contained item based on the AbsoluteAxis passed
     pub fn get(&self, axis: AbsoluteAxis) -> T {
         match axis {
diff --git a/src/compute/mod.rs b/src/compute/mod.rs
index 479644b91..31d783b07 100644
--- a/src/compute/mod.rs
+++ b/src/compute/mod.rs
@@ -17,6 +17,7 @@ use crate::sys::round;
 use crate::tree::LayoutTree;
 
 use self::flexbox::FlexboxAlgorithm;
+#[cfg(feature = "grid")]
 use self::grid::CssGridAlgorithm;
 use self::leaf::LeafAlgorithm;
 
diff --git a/src/prelude.rs b/src/prelude.rs
index effc57d7c..db21a6df2 100644
--- a/src/prelude.rs
+++ b/src/prelude.rs
@@ -32,8 +32,8 @@ pub use crate::{
         JustifyContent, JustifyItems, JustifySelf, LengthPercentage, LengthPercentageAuto, Position, Style,
     },
     style_helpers::{
-        auto, evenly_sized_tracks, fit_content, flex, fr, max_content, min_content, minmax, percent, points, zero,
-        FromFlex, FromPercent, FromPoints, TaffyAuto, TaffyFitContent, TaffyMaxContent, TaffyMinContent, TaffyZero,
+        auto, fit_content, max_content, min_content, percent, points, zero, FromFlex, FromPercent, FromPoints,
+        TaffyAuto, TaffyFitContent, TaffyMaxContent, TaffyMinContent, TaffyZero,
     },
     tree::LayoutTree,
 };
@@ -44,4 +44,6 @@ pub use crate::style::{
     NonRepeatedTrackSizingFunction, TrackSizingFunction,
 };
 #[cfg(feature = "grid")]
-pub use crate::style_helpers::{line, repeat, span, TaffyGridLine, TaffyGridSpan};
+pub use crate::style_helpers::{
+    evenly_sized_tracks, flex, fr, line, minmax, repeat, span, TaffyGridLine, TaffyGridSpan,
+};
diff --git a/src/style_helpers.rs b/src/style_helpers.rs
index 7e1f55082..f7591cdbe 100644
--- a/src/style_helpers.rs
+++ b/src/style_helpers.rs
@@ -1,15 +1,19 @@
 //! Helper functions which it make it easier to create instances of types in the `style` and `geometry` modules.
 use crate::{
-    geometry::{Line, MinMax, Point, Rect, Size},
+    geometry::{Line, Point, Rect, Size},
     style::LengthPercentage,
 };
-use core::fmt::Debug;
 
 #[cfg(feature = "grid")]
-use crate::style::{
-    GridTrackRepetition, MaxTrackSizingFunction, MinTrackSizingFunction, NonRepeatedTrackSizingFunction,
-    TrackSizingFunction,
+use crate::{
+    geometry::MinMax,
+    style::{
+        GridTrackRepetition, MaxTrackSizingFunction, MinTrackSizingFunction, NonRepeatedTrackSizingFunction,
+        TrackSizingFunction,
+    },
 };
+#[cfg(feature = "grid")]
+use core::fmt::Debug;
 
 /// Returns an auto-repeated track definition
 #[cfg(feature = "grid")]
@@ -527,6 +531,7 @@ impl<T: FromPercent> Rect<T> {
 }
 
 /// Create a `Fraction` track sizing function (`fr` in CSS)
+#[cfg(feature = "grid")]
 pub fn fr<Input: Into<f32> + Copy, T: FromFlex>(flex: Input) -> T {
     T::from_flex(flex)
 }
diff --git a/src/sys.rs b/src/sys.rs
index 134b22782..de8fb05ca 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -13,7 +13,6 @@ pub(crate) use self::alloc::*;
 pub(crate) use self::core::*;
 
 /// Returns the largest of two f32 values
-#[cfg(feature = "grid")]
 pub(crate) fn f32_max(a: f32, b: f32) -> f32 {
     core::cmp::max_by(a, b, |a, b| a.total_cmp(b))
 }