Skip to content
Permalink
Browse files

Use std::mem::take instead of defining it

  • Loading branch information
SimonSapin committed Nov 26, 2019
1 parent b2b3ea9 commit 80eec48d373f89415e95e01ab9aaf6d07ac01c3e
@@ -10,7 +10,6 @@ use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
use crate::formatting_contexts::IndependentFormattingContext;
use crate::positioned::AbsolutelyPositionedBox;
use crate::style_ext::{DisplayGeneratingBox, DisplayInside, DisplayOutside};
use crate::take;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rayon_croissant::ParallelIteratorExt;
use servo_arc::Arc;
@@ -381,7 +380,7 @@ where
// The fragmented boxes before the block level element
// are obviously not the last fragment.
last_fragment: false,
children: take(&mut ongoing.children),
children: std::mem::take(&mut ongoing.children),
};
ongoing.first_fragment = false;
fragmented
@@ -516,7 +515,7 @@ where

let box_ = IntermediateBlockLevelBox::SameFormattingContextBlock {
style: anonymous_style.clone(),
contents: IntermediateBlockContainer::InlineFormattingContext(take(
contents: IntermediateBlockContainer::InlineFormattingContext(std::mem::take(
&mut self.ongoing_inline_formatting_context,
)),
};
@@ -12,7 +12,7 @@ use crate::geom::flow_relative::{Rect, Sides, Vec2};
use crate::positioned::{AbsolutelyPositionedBox, AbsolutelyPositionedFragment};
use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside};
use crate::{relative_adjustement, take, ContainingBlock};
use crate::{relative_adjustement, ContainingBlock};
use servo_arc::Arc;
use style::properties::ComputedValues;
use style::values::computed::Length;
@@ -185,7 +185,7 @@ impl LinesBoxes {
};
self.next_line_block_position += size.block;
self.boxes.push(Fragment::Anonymous(AnonymousFragment {
children: take(&mut top_nesting_level.fragments_so_far),
children: std::mem::take(&mut top_nesting_level.fragments_so_far),
rect: Rect { start_corner, size },
mode: containing_block.mode,
}))
@@ -250,7 +250,7 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> {
) {
let mut fragment = BoxFragment {
style: self.style.clone(),
children: take(&mut nesting_level.fragments_so_far),
children: std::mem::take(&mut nesting_level.fragments_so_far),
content_rect: Rect {
size: Vec2 {
inline: *inline_position - self.start_corner.inline,
@@ -81,12 +81,3 @@ fn relative_adjustement(
block: adjust(box_offsets.block_start, box_offsets.block_end),
}
}

// FIXME: use std::mem::take when it’s stable.
// https://github.com/rust-lang/rust/issues/61129
fn take<T>(x: &mut T) -> T
where
T: Default,
{
std::mem::replace(x, Default::default())
}

0 comments on commit 80eec48

Please sign in to comment.
You can’t perform that action at this time.