Skip to content

Commit

Permalink
Make robinson build with Rust 1.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Apr 8, 2015
1 parent 5c008e2 commit 1621c38
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
21 changes: 15 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Coming soon, I hope:
Instructions
------------

1. [Install Rust from the *Nightly* channel.](http://www.rust-lang.org/install.html)
1. [Install Rust 1.0 beta or newer.](http://www.rust-lang.org/install.html)

2. Clone the robinson source code from https://github.com/mbrubeck/robinson

Expand Down
9 changes: 6 additions & 3 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use style::{StyledNode, Display};
use css::Value::{Keyword, Length};
use css::Unit::Px;
use std::default::Default;
use std::iter::AdditiveIterator; // for `sum`

pub use self::BoxType::{AnonymousBlock, InlineNode, BlockNode};

Expand Down Expand Up @@ -149,8 +148,8 @@ impl<'a> LayoutBox<'a> {
let padding_left = style.lookup("padding-left", "padding", &zero);
let padding_right = style.lookup("padding-right", "padding", &zero);

let total = [&margin_left, &margin_right, &border_left, &border_right,
&padding_left, &padding_right, &width].iter().map(|v| v.to_px()).sum();
let total = sum([&margin_left, &margin_right, &border_left, &border_right,
&padding_left, &padding_right, &width].iter().map(|v| v.to_px()));

// If width is not auto and the total is wider than the container, treat auto margins as 0.
if width != auto && total > containing_block.content.width {
Expand Down Expand Up @@ -305,3 +304,7 @@ impl Dimensions {
self.border_box().expanded_by(self.margin)
}
}

fn sum<I>(iter: I) -> f32 where I: Iterator<Item=f32> {
iter.fold(0., |a, b| a + b)
}
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(core)]

extern crate getopts;
extern crate image;

Expand Down

0 comments on commit 1621c38

Please sign in to comment.