Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: derive Debug and PartialEq for tree types #697

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tree/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::tree::{LayoutOutput, RunMode};
const CACHE_SIZE: usize = 9;

/// Cached intermediate layout results
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub(crate) struct CacheEntry<T> {
/// The initial cached size of the node itself
Expand All @@ -19,7 +19,7 @@ pub(crate) struct CacheEntry<T> {
}

/// A cache for caching the results of a sizing a Grid Item or Flexbox Item
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Cache {
/// The cache entry for the node's final layout
Expand Down
8 changes: 4 additions & 4 deletions src/tree/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl CollapsibleMarginSet {
}

/// An axis that layout algorithms can be requested to compute a size for
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub enum RequestedAxis {
/// The horizontal axis
Expand Down Expand Up @@ -106,7 +106,7 @@ impl TryFrom<RequestedAxis> for AbsoluteAxis {
}

/// A struct containing the inputs constraints/hints for laying out a node, which are passed in by the parent
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct LayoutInput {
/// Whether we only need to know the Node's size, or whe
Expand Down Expand Up @@ -156,7 +156,7 @@ impl LayoutInput {
/// children that may be text nodes. See <https://www.w3.org/TR/css-writing-modes-3/#intro-baselines> for details.
/// If your node does not have a baseline (or you are unsure how to compute it), then simply return `Point::NONE`
/// for the first_baselines field
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct LayoutOutput {
/// The size of the node
Expand Down Expand Up @@ -221,7 +221,7 @@ impl LayoutOutput {
}

/// The final result of a layout algorithm for a single node.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Layout {
/// The relative ordering of the node
Expand Down
5 changes: 4 additions & 1 deletion src/tree/taffy_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl core::fmt::Display for TaffyError {
impl std::error::Error for TaffyError {}

/// Global configuration values for a TaffyTree instance
#[derive(Debug, Clone, Copy)]
pub(crate) struct TaffyConfig {
/// Whether to round layout values
pub(crate) use_rounding: bool,
Expand All @@ -80,6 +81,7 @@ impl Default for TaffyConfig {
/// Layout information for a given [`Node`](crate::node::Node)
///
/// Stored in a [`TaffyTree`].
#[derive(Debug, Clone, PartialEq)]
struct NodeData {
/// The layout strategy used by this node
pub(crate) style: Style,
Expand Down Expand Up @@ -123,7 +125,8 @@ impl NodeData {

/// An entire tree of UI nodes. The entry point to Taffy's high-level API.
///
/// Allows you to build a tree of UI nodes, run Taffy's layout algorithms over that tree, and then access the resultant layout.
/// Allows you to build a tree of UI nodes, run Taffy's layout algorithms over that tree, and then access the resultant layout.]
#[derive(Debug, Clone)]
pub struct TaffyTree<NodeContext = ()> {
/// The [`NodeData`] for each node stored in this tree
nodes: SlotMap<DefaultKey, NodeData>,
Expand Down