Skip to content

LayoutTree trait is coupled to slotmap #327

@nicoburns

Description

@nicoburns

Issue

Almost all of the methods in the LayoutTree trait either take a taffy::Node (which is an alias for slotmap::DefaultKey) as a parameter or are required to return one. But the only way to create or use a slotmap::DefaultKey is to depend on the slotmap crate and actually a have a slotmap allocated in memory!

This is not ideal considering the whole point of the LayoutTree trait is to enable alternative storage backends.

Context

The LayoutTree trait definition: https://github.com/DioxusLabs/taffy/blob/main/src/tree.rs

I'm currently trying to create a grid widget for iced using Taffy for layout. Hopefully this should be a good test case that will surface issues like this that make Taffy to integrate with.

Proposal

The LayoutTree trait should be decoupled from slotmap. Possibly by making the node id an associated type on the trait, or just standardising on u64 instead of slotmap::DefaultKey.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeA change that breaks our public interfaceusabilityMake the library more comfortable to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions