Repository: servo/servo
File: components/layout/flexbox/mod.rs (Rust)

Code before:
        }
    }

    pub(crate) fn with_base<T>(&self, callback: impl FnOnce(&LayoutBoxBase) -> T) -> T {
        match self {
            FlexLevelBox::FlexItem(flex_item_box) => {
                callback(&flex_item_box.independent_formatting_context.base)
            },
            FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                callback(&positioned_box.borrow().context.base)
            },
        }
    }

    pub(crate) fn with_base_mut<T>(&mut self, callback: impl FnOnce(&mut LayoutBoxBase) -> T) -> T {
        match self {
            FlexLevelBox::FlexItem(flex_item_box) => {
                callback(&mut flex_item_box.independent_formatting_context.base)
            },
            FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                callback(&mut positioned_box.borrow_mut().context.base)
            },
        }
    }

    pub(crate) fn attached_to_tree(&self, box_: WeakLayoutBox) {
        match self {
            Self::FlexItem(flex_item_box) => flex_item_box
                .independent_formatting_context
                .attached_to_tree(box_),
            Self::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                positioned_box.borrow_mut().context.attached_to_tree(box_)
            },
        }
    }
}

#[derive(MallocSizeOf)]
pub(crate) struct FlexItemBox {
    independent_formatting_context: IndependentFormattingContext,
}

impl std::fmt::Debug for FlexItemBox {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str("FlexItemBox")
    }
}

impl FlexItemBox {
    fn new(independent_formatting_context: IndependentFormattingContext) -> Self {
        Self {

Review comment (suggestion):
```suggestion
    pub(crate) fn attached_to_tree(&self, layout_box: WeakLayoutBox) {
```

Code after:
        }
    }

    pub(crate) fn with_base<T>(&self, callback: impl FnOnce(&LayoutBoxBase) -> T) -> T {
        match self {
            FlexLevelBox::FlexItem(flex_item_box) => {
                callback(&flex_item_box.independent_formatting_context.base)
            },
            FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                callback(&positioned_box.borrow().context.base)
            },
        }
    }

    pub(crate) fn with_base_mut<T>(&mut self, callback: impl FnOnce(&mut LayoutBoxBase) -> T) -> T {
        match self {
            FlexLevelBox::FlexItem(flex_item_box) => {
                callback(&mut flex_item_box.independent_formatting_context.base)
            },
            FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                callback(&mut positioned_box.borrow_mut().context.base)
            },
        }
    }

    pub(crate) fn attached_to_tree(&self, layout_box: WeakLayoutBox) {
        match self {
            Self::FlexItem(flex_item_box) => flex_item_box
                .independent_formatting_context
                .attached_to_tree(layout_box),
            Self::OutOfFlowAbsolutelyPositionedBox(positioned_box) => positioned_box
                .borrow_mut()
                .context
                .attached_to_tree(layout_box),
        }
    }
}

#[derive(MallocSizeOf)]
pub(crate) struct FlexItemBox {
    independent_formatting_context: IndependentFormattingContext,
}

impl std::fmt::Debug for FlexItemBox {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str("FlexItemBox")
    }
}

impl FlexItemBox {
    fn new(independent_formatting_context: IndependentFormattingContext) -> Self {