gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62286 Definiciones

Upgrade rand and rand_chacha (bench deps) to 0.9 (#798)

* Upgrade rand and rand_chacha (bench deps) to 0.9

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix overindented doc lint

* Fix yoga bench compilation

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>

ff58be174437ec68447b7e7edf40e7fcc382fdbd · por Nico Burns · (hace 1 año) · padre 10ca36531 · ver el árbol en este commit

Delta semántico · 7

benches/benches/flexbox.rs

benches/benches/grid.rs

benches/benches/tree_creation.rs

benches/src/taffy_03_helpers.rs

benches/src/taffy_helpers.rs

benches/src/yoga_helpers.rs

10 archivos · +46 −46

diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index c7a0cd2a4..d4e72bc4b 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -14,8 +14,8 @@ license = "MIT"
 
 [dependencies]
 criterion = "0.5"
-rand = { version = "0.8.5" }
-rand_chacha = "0.3.1"
+rand = { version = "0.9" }
+rand_chacha = "0.9"
 taffy = { path = ".." }
 taffy_03 = { package = "taffy", version = "0.3", optional = true }
 yoga = { version = "0.5.0", optional = true }
diff --git a/benches/benches/flexbox.rs b/benches/benches/flexbox.rs
index e2b1b5b0d..e2f7596d5 100644
--- a/benches/benches/flexbox.rs
+++ b/benches/benches/flexbox.rs
@@ -13,10 +13,10 @@ use taffy_benchmarks::taffy_03_helpers::Taffy03TreeBuilder;
 use taffy_benchmarks::yoga_helpers::YogaTreeBuilder;
 
 fn random_dimension(rng: &mut impl Rng) -> Dimension {
-    match rng.gen_range(0.0..=1.0) {
+    match rng.random_range(0.0..=1.0) {
         rand if rand < 0.2 => auto(),
-        rand if rand < 0.8 => length(rng.gen_range(0.0..500.0)),
-        _ => percent(rng.gen_range(0.0..1.0)),
+        rand if rand < 0.8 => length(rng.random_range(0.0..500.0)),
+        _ => percent(rng.random_range(0.0..1.0)),
     }
 }
 
diff --git a/benches/benches/grid.rs b/benches/benches/grid.rs
index 4d342e482..f570bdf7b 100644
--- a/benches/benches/grid.rs
+++ b/benches/benches/grid.rs
@@ -12,7 +12,7 @@ fn build_random_leaf(taffy: &mut TaffyTree, _rng: &mut ChaCha8Rng) -> NodeId {
 }
 
 fn random_grid_track<R: Rng>(rng: &mut R) -> TrackSizingFunction {
-    let switch: f32 = rng.gen_range(0.0..=1.0);
+    let switch: f32 = rng.random_range(0.0..=1.0);
     if switch < 0.1 {
         auto()
     } else if switch < 0.2 {
diff --git a/benches/benches/tree_creation.rs b/benches/benches/tree_creation.rs
index 52c9052eb..b850a7091 100644
--- a/benches/benches/tree_creation.rs
+++ b/benches/benches/tree_creation.rs
@@ -26,7 +26,7 @@ fn build_taffy_flat_hierarchy(total_node_count: u32, use_with_capacity: bool) ->
     let mut node_count = 0;
 
     while node_count < total_node_count {
-        let sub_children_count = rng.gen_range(1..=4);
+        let sub_children_count = rng.random_range(1..=4);
         let sub_children: Vec<NodeId> = (0..sub_children_count).map(|_| build_random_leaf(&mut taffy)).collect();
         let node = taffy.new_with_children(Style::DEFAULT, &sub_children).unwrap();
 
@@ -47,7 +47,7 @@ fn build_yoga_flat_hierarchy(total_node_count: u32) -> (yg::YogaTree, yg::NodeId
     let mut node_count = 0;
 
     while node_count < total_node_count {
-        let sub_children_count = rng.gen_range(1..=4);
+        let sub_children_count = rng.random_range(1..=4);
         let sub_children: Vec<yg::NodeId> =
             (0..sub_children_count).map(|_| yoga_helpers::new_default_style_with_children(&mut tree, &[])).collect();
         let node = yoga_helpers::new_default_style_with_children(&mut tree, &sub_children);
diff --git a/benches/src/lib.rs b/benches/src/lib.rs
index b2f5b651f..d98ec1ff0 100644
--- a/benches/src/lib.rs
+++ b/benches/src/lib.rs
@@ -13,7 +13,7 @@ pub mod yoga_helpers;
 #[cfg(feature = "yoga")]
 pub use yoga_helpers::YogaTreeBuilder;
 
-use rand::distributions::uniform::SampleRange;
+use rand::distr::uniform::SampleRange;
 use rand::{Rng, SeedableRng};
 use rand_chacha::ChaCha8Rng;
 use taffy::style::Style as TaffyStyle;
diff --git a/benches/src/taffy_03_helpers.rs b/benches/src/taffy_03_helpers.rs
index a9a044f2e..33c2b8faf 100644
--- a/benches/src/taffy_03_helpers.rs
+++ b/benches/src/taffy_03_helpers.rs
@@ -31,7 +31,7 @@ impl<R: Rng, G: GenStyle<TaffyStyle>> BuildTree<R, G> for Taffy03TreeBuilder<R,
     }
 
     fn random_usize(&mut self, range: impl SampleRange<usize>) -> usize {
-        self.rng.gen_range(range)
+        self.rng.random_range(range)
     }
 
     fn create_leaf_node(&mut self) -> Self::Node {
diff --git a/benches/src/taffy_helpers.rs b/benches/src/taffy_helpers.rs
index 9405775f2..26ac536f0 100644
--- a/benches/src/taffy_helpers.rs
+++ b/benches/src/taffy_helpers.rs
@@ -1,4 +1,4 @@
-use rand::distributions::uniform::SampleRange;
+use rand::distr::uniform::SampleRange;
 use rand::Rng;
 use rand_chacha::ChaCha8Rng;
 use taffy::style::Style as TaffyStyle;
@@ -32,7 +32,7 @@ impl<R: Rng, G: GenStyle<TaffyStyle>> BuildTree<R, G> for TaffyTreeBuilder<R, G>
     }
 
     fn random_usize(&mut self, range: impl SampleRange<usize>) -> usize {
-        self.rng.gen_range(range)
+        self.rng.random_range(range)
     }
 
     fn create_leaf_node(&mut self) -> Self::Node {
diff --git a/benches/src/yoga_helpers.rs b/benches/src/yoga_helpers.rs
index d46a8cd52..f91280dee 100644
--- a/benches/src/yoga_helpers.rs
+++ b/benches/src/yoga_helpers.rs
@@ -1,6 +1,6 @@
 #![allow(dead_code)]
 
-use rand::distributions::uniform::SampleRange;
+use rand::distr::uniform::SampleRange;
 use rand::Rng;
 use rand_chacha::ChaCha8Rng;
 use slotmap::{DefaultKey, SlotMap};
@@ -49,7 +49,7 @@ impl<R: Rng, G: GenStyle<TaffyStyle>> BuildTree<R, G> for YogaTreeBuilder<R, G>
     }
 
     fn random_usize(&mut self, range: impl SampleRange<usize>) -> usize {
-        self.rng.gen_range(range)
+        self.rng.random_range(range)
     }
 
     fn create_leaf_node(&mut self) -> Self::Node {
diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 90d526440..e5c4aef8a 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -624,19 +624,19 @@ fn determine_available_space(
 ///         - a used flex basis of content, and
 ///         - a definite cross size,
 ///
-///     then the flex base size is calculated from its inner cross size and the flex item’s intrinsic aspect ratio.
+///       then the flex base size is calculated from its inner cross size and the flex item’s intrinsic aspect ratio.
 ///
 ///     - C. If the used flex basis is content or depends on its available space, and the flex container is being sized under a min-content
-///         or max-content constraint (e.g. when performing automatic table layout \[CSS21\]), size the item under that constraint.
-///         The flex base size is the item’s resulting main size.
+///       or max-content constraint (e.g. when performing automatic table layout \[CSS21\]), size the item under that constraint.
+///       The flex base size is the item’s resulting main size.
 ///
 ///     - E. Otherwise, size the item into the available space using its used flex basis in place of its main size, treating a value of content as max-content.
-///         If a cross size is needed to determine the main size (e.g. when the flex item’s main size is in its block axis) and the flex item’s cross size is auto and not definite,
-///         in this calculation use fit-content as the flex item’s cross size. The flex base size is the item’s resulting main size.
+///       If a cross size is needed to determine the main size (e.g. when the flex item’s main size is in its block axis) and the flex item’s cross size is auto and not definite,
+///       in this calculation use fit-content as the flex item’s cross size. The flex base size is the item’s resulting main size.
 ///
-///     When determining the flex base size, the item’s min and max main sizes are ignored (no clamping occurs).
-///     Furthermore, the sizing calculations that floor the content box size at zero when applying box-sizing are also ignored.
-///     (For example, an item with a specified size of zero, positive padding, and box-sizing: border-box will have an outer flex base size of zero—and hence a negative inner flex base size.)
+///   When determining the flex base size, the item’s min and max main sizes are ignored (no clamping occurs).
+///   Furthermore, the sizing calculations that floor the content box size at zero when applying box-sizing are also ignored.
+///   (For example, an item with a specified size of zero, positive padding, and box-sizing: border-box will have an outer flex base size of zero—and hence a negative inner flex base size.)
 #[inline]
 fn determine_flex_base_size(
     tree: &mut impl LayoutFlexboxContainer,
@@ -834,14 +834,14 @@ fn determine_flex_base_size(
 ///     - If the flex container is single-line, collect all the flex items into a single flex line.
 ///
 ///     - Otherwise, starting from the first uncollected item, collect consecutive items one by one until the first time that the next collected item would not fit into the flex container’s inner main size
-///         (or until a forced break is encountered, see [§10 Fragmenting Flex Layout](https://www.w3.org/TR/css-flexbox-1/#pagination)).
-///         If the very first uncollected item wouldn't fit, collect just it into the line.
+///       (or until a forced break is encountered, see [§10 Fragmenting Flex Layout](https://www.w3.org/TR/css-flexbox-1/#pagination)).
+///       If the very first uncollected item wouldn't fit, collect just it into the line.
 ///
-///         For this step, the size of a flex item is its outer hypothetical main size. (**Note: This can be negative**.)
+///       For this step, the size of a flex item is its outer hypothetical main size. (**Note: This can be negative**.)
 ///
-///         Repeat until all flex items have been collected into flex lines.
+///       Repeat until all flex items have been collected into flex lines.
 ///
-///         **Note that the "collect as many" line will collect zero-sized flex items onto the end of the previous line even if the last non-zero item exactly "filled up" the line**.
+///       **Note that the "collect as many" line will collect zero-sized flex items onto the end of the previous line even if the last non-zero item exactly "filled up" the line**.
 #[inline]
 fn collect_flex_lines<'a>(
     constants: &AlgoConstants,
@@ -1355,7 +1355,7 @@ fn resolve_flexible_lengths(line: &mut FlexLine, constants: &AlgoConstants) {
 /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing)
 ///
 /// - [**Determine the hypothetical cross size of each item**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-item)
-///     by performing layout with the used main size and the available space, treating auto as fit-content.
+///   by performing layout with the used main size and the available space, treating auto as fit-content.
 #[inline]
 fn determine_hypothetical_cross_size(
     tree: &mut impl LayoutFlexboxContainer,
@@ -1544,8 +1544,8 @@ fn calculate_cross_size(flex_lines: &mut [FlexLine], node_size: Size<Option<f32>
 /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing)
 ///
 /// - [**Handle 'align-content: stretch'**](https://www.w3.org/TR/css-flexbox-1/#algo-line-stretch). If the flex container has a definite cross size, align-content is stretch,
-///     and the sum of the flex lines' cross sizes is less than the flex container’s inner cross size,
-///     increase the cross size of each flex line by equal amounts such that the sum of their cross sizes exactly equals the flex container’s inner cross size.
+///   and the sum of the flex lines' cross sizes is less than the flex container’s inner cross size,
+///   increase the cross size of each flex line by equal amounts such that the sum of their cross sizes exactly equals the flex container’s inner cross size.
 #[inline]
 fn handle_align_content_stretch(flex_lines: &mut [FlexLine], node_size: Size<Option<f32>>, constants: &AlgoConstants) {
     if constants.align_content == AlignContent::Stretch {
@@ -1576,12 +1576,12 @@ fn handle_align_content_stretch(flex_lines: &mut [FlexLine], node_size: Size<Opt
 /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing)
 ///
 /// - [**Determine the used cross size of each flex item**](https://www.w3.org/TR/css-flexbox-1/#algo-stretch). If a flex item has align-self: stretch, its computed cross size property is auto,
-///     and neither of its cross-axis margins are auto, the used outer cross size is the used cross size of its flex line, clamped according to the item’s used min and max cross sizes.
-///     Otherwise, the used cross size is the item’s hypothetical cross size.
+///   and neither of its cross-axis margins are auto, the used outer cross size is the used cross size of its flex line, clamped according to the item’s used min and max cross sizes.
+///   Otherwise, the used cross size is the item’s hypothetical cross size.
 ///
-///     If the flex item has align-self: stretch, redo layout for its contents, treating this used size as its definite cross size so that percentage-sized children can be resolved.
+///   If the flex item has align-self: stretch, redo layout for its contents, treating this used size as its definite cross size so that percentage-sized children can be resolved.
 ///
-///     **Note that this step does not affect the main size of the flex item, even if it has an intrinsic aspect ratio**.
+///   **Note that this step does not affect the main size of the flex item, even if it has an intrinsic aspect ratio**.
 #[inline]
 fn determine_used_cross_size(
     tree: &impl LayoutFlexboxContainer,
@@ -1641,10 +1641,10 @@ fn determine_used_cross_size(
 ///
 /// - [**Distribute any remaining free space**](https://www.w3.org/TR/css-flexbox-1/#algo-main-align). For each flex line:
 ///
-///     1. If the remaining free space is positive and at least one main-axis margin on this line is `auto`, distribute the free space equally among these margins.
-///         Otherwise, set all `auto` margins to zero.
+///   1. If the remaining free space is positive and at least one main-axis margin on this line is `auto`, distribute the free space equally among these margins.
+///      Otherwise, set all `auto` margins to zero.
 ///
-///     2. Align the items along the main-axis per `justify-content`.
+///   2. Align the items along the main-axis per `justify-content`.
 #[inline]
 fn distribute_remaining_free_space(flex_lines: &mut [FlexLine], constants: &AlgoConstants) {
     for line in flex_lines {
@@ -1710,13 +1710,13 @@ fn distribute_remaining_free_space(flex_lines: &mut [FlexLine], constants: &Algo
 /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment)
 ///
 /// - [**Resolve cross-axis `auto` margins**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-margins).
-///     If a flex item has auto cross-axis margins:
+///   If a flex item has auto cross-axis margins:
 ///
-///     - If its outer cross size (treating those auto margins as zero) is less than the cross size of its flex line,
-///         distribute the difference in those sizes equally to the auto margins.
+///   - If its outer cross size (treating those auto margins as zero) is less than the cross size of its flex line,
+///     distribute the difference in those sizes equally to the auto margins.
 ///
-///     - Otherwise, if the block-start or inline-start margin (whichever is in the cross axis) is auto, set it to zero.
-///         Set the opposite margin so that the outer cross size of the item equals the cross size of its flex line.
+///   - Otherwise, if the block-start or inline-start margin (whichever is in the cross axis) is auto, set it to zero.
+///     Set the opposite margin so that the outer cross size of the item equals the cross size of its flex line.
 #[inline]
 fn resolve_cross_axis_auto_margins(flex_lines: &mut [FlexLine], constants: &AlgoConstants) {
     for line in flex_lines {
@@ -1759,7 +1759,7 @@ fn resolve_cross_axis_auto_margins(flex_lines: &mut [FlexLine], constants: &Algo
 /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment)
 ///
 /// - [**Align all flex items along the cross-axis**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-align) per `align-self`,
-///     if neither of the item's cross-axis margins are `auto`.
+///   if neither of the item's cross-axis margins are `auto`.
 #[inline]
 fn align_flex_items_along_cross_axis(
     child: &FlexItem,
diff --git a/src/tree/traits.rs b/src/tree/traits.rs
index 8837d3f18..9c291c824 100644
--- a/src/tree/traits.rs
+++ b/src/tree/traits.rs
@@ -35,10 +35,10 @@
 //! ### TraversePartialTree and TraverseTree
 //! These traits are Taffy's abstraction for downward tree traversal:
 //!  - [`TraversePartialTree`] allows access to a single container node, and it's immediate children. This is the only "traverse" trait that is required
-//!     for use of Taffy's core layout algorithms (flexbox, grid, etc).
+//!    for use of Taffy's core layout algorithms (flexbox, grid, etc).
 //!  - [`TraverseTree`] is a marker trait which uses the same API signature as `TraversePartialTree`, but extends it with a guarantee that the child/children methods can be used to recurse
-//!     infinitely down the tree. It is required by the `RoundTree` and
-//!     the `PrintTree` traits.
+//!    infinitely down the tree. It is required by the `RoundTree` and
+//!    the `PrintTree` traits.
 //! ```rust
 //! # use taffy::*;
 //! pub trait TraversePartialTree {