diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 25f3fb895..157a072f6 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -56,6 +56,8 @@ pub trait LayoutTree { fn compute_child_layout(&mut self, node_id: NodeId, inputs: LayoutInput) -> LayoutOutput; } +/// A private trait which allows us to add extra convenience methods to types which implement +/// LayoutTree without making those methods public. pub(crate) trait LayoutTreeExt: LayoutTree { /// Compute the size of the node given the specified constraints #[inline(always)] diff --git a/src/tree/taffy_tree/tree.rs b/src/tree/taffy_tree/tree.rs index f68147e9c..de4bdde90 100644 --- a/src/tree/taffy_tree/tree.rs +++ b/src/tree/taffy_tree/tree.rs @@ -161,11 +161,14 @@ where inputs, style, Some(|known_dimensions, available_space| { - (&mut self.measure_function)(known_dimensions, available_space, node, node_context) + (self.measure_function)(known_dimensions, available_space, node, node_context) }), ) } else { - let measure_function: Option>, Size) -> Size> = None; + /// Type inference gets confused because we're just passing None here. So we give + /// it a concrete type to work with (even though we never construct the inner type) + type DummyMeasureFunction = Option>, Size) -> Size>; + let measure_function: DummyMeasureFunction = None; compute_leaf_layout(inputs, style, measure_function) } }