Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[not ready for review yet] Allow calc expressions when parsing numbers #7308

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Get rid of some cloning

  • Loading branch information
dzbarsky committed Aug 21, 2015
commit 5e47273e95d285259fc059d3076e7c14ad20f577
@@ -502,9 +502,8 @@ pub mod specified {
}

fn simplify_sum_to_number(node: &CalcSumNode) -> Option<CSSFloat> {
let node = node.clone();
let mut sum = 0.;
for product in node.products {
for product in &node.products {
match Calc::simplify_product_to_number(product) {
Some(number) => sum += number,
_ => return None
@@ -513,10 +512,10 @@ pub mod specified {
Some(sum)
}

fn simplify_product_to_number(node: CalcProductNode) -> Option<CSSFloat> {
fn simplify_product_to_number(node: &CalcProductNode) -> Option<CSSFloat> {
let mut product = 1.;
for value in node.values {
match Calc::simplify_value_to_number(&value) {
for value in &node.values {
match Calc::simplify_value_to_number(value) {
Some(number) => product *= number,
_ => return None
}
@@ -526,8 +525,7 @@ pub mod specified {

fn simplify_products_in_sum(node: &CalcSumNode) -> Result<SimplifiedValueNode, ()> {
let mut simplified = Vec::new();
let node = node.clone();
for product in node.products {
for product in &node.products {
match try!(Calc::simplify_product(product)) {
SimplifiedValueNode::Sum(box sum) => simplified.push_all(&sum.values),
val => simplified.push(val),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.