use std::fmt;

static ROMAN_MAP: [(usize, &'static str); 13] = [
    (1, "I"),
    (4, "IV"),
    (5, "V"),
    (9, "IX"),
    (10, "X"),
    (40, "XL"),
    (50, "L"),
    (90, "XC"),
    (100, "C"),
    (400, "CD"),
    (500, "D"),
    (900, "CM"),
    (1000, "M"),
];

pub struct Roman {
    num: usize,
}

impl From<usize> for Roman {
    fn from(i: usize) -> Self {
        Roman::new(i)
    }
}

impl fmt::Display for Roman {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut start = self.num.clone();
        let mut result = String::new();
        for &(numeric, roman_string) in ROMAN_MAP.into_iter().rev() {
            while start >= numeric {
                result.push_str(roman_string);
                start -= numeric;
            }
        }
        write!(f, "{}", result)
    }
}

impl Roman {
    fn new(num: usize) -> Roman {
        Roman { num }
    }
}

use std::fmt;

static ROMAN_MAP: [(usize, &'static str); 13] = [
    (1, "I"),
    (4, "IV"),
    (5, "V"),
    (9, "IX"),
    (10, "X"),
    (40, "XL"),
    (50, "L"),
    (90, "XC"),
    (100, "C"),
    (400, "CD"),
    (500, "D"),
    (900, "CM"),
    (1000, "M"),
];

pub struct Roman {
    num: usize,
}

impl From<usize> for Roman {
    fn from(i: usize) -> Self {
        Roman::new(i)
    }
}

impl fmt::Display for Roman {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut start = self.num.clone();
        let mut result = String::new();
        for &(numeric, roman_string) in ROMAN_MAP.iter().rev() {
            while start >= numeric {
                result.push_str(roman_string);
                start -= numeric;
            }
        }
        write!(f, "{}", result)
    }
}

impl Roman {
    fn new(num: usize) -> Roman {
        Roman { num }
    }
}

Use `iter` instead of `into_iter` when not moving
roman-numerals: Use `iter` instead of `into_iter` when not moving

Clippy suggested
https://travis-ci.org/exercism/rust/builds/456432005
error: this .into_iter() call is equivalent to .iter() and will not move the array
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#into_iter_on_array

(compare to 75c1bf93b7045bcd25aa178a8cecf1da4bb422fc which was on
slices. Apparently this is considered a warning for slices but an error
on arrays)
