Auto merge of #8167 - Ms2ger:util, r=nox

Various cleanup in util.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8167)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-10-23 07:00:09 -06:00
commit 94aa8ca80a
3 changed files with 8 additions and 6 deletions

View file

@ -89,7 +89,9 @@ pub static MAX_RECT: Rect<Au> = Rect {
/// Returns true if the rect contains the given point. Points on the top or left sides of the rect
/// are considered inside the rectangle, while points on the right or bottom sides of the rect are
/// not considered inside the rectangle.
pub fn rect_contains_point<T: PartialOrd + Add<T, Output=T>>(rect: Rect<T>, point: Point2D<T>) -> bool {
pub fn rect_contains_point<T>(rect: Rect<T>, point: Point2D<T>) -> bool
where T: PartialOrd + Add<T, Output=T>
{
point.x >= rect.origin.x && point.x < rect.origin.x + rect.size.width &&
point.y >= rect.origin.y && point.y < rect.origin.y + rect.size.height
}

View file

@ -319,8 +319,10 @@ impl<T: Sub<T, Output=T>> Sub for LogicalSize<T> {
/// A 2D point in flow-relative dimensions
#[derive(PartialEq, RustcEncodable, Eq, Clone, Copy)]
pub struct LogicalPoint<T> {
pub i: T, /// inline-axis coordinate
pub b: T, /// block-axis coordinate
/// inline-axis coordinate
pub i: T,
/// block-axis coordinate
pub b: T,
debug_writing_mode: DebugWritingMode,
}

View file

@ -12,9 +12,7 @@ pub fn spawn_named<F>(name: String, f: F)
where F: FnOnce() + Send + 'static
{
let builder = thread::Builder::new().name(name);
builder.spawn(move || {
f()
}).unwrap();
builder.spawn(f).unwrap();
}
/// Arrange to send a particular message to a channel if the task fails.