From 8e430d6952f66bc6d0fdc7843cb8ce7373595c7d Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:25:33 +0100 Subject: [PATCH] nl: fix build --- src/nl/helper.rs | 3 ++- src/nl/nl.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nl/helper.rs b/src/nl/helper.rs index 0b6c4cdf4..7b8cc66d9 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -8,7 +8,8 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> { ['t'] => { Ok(::NumberingStyle::NumberForNonEmpty) }, ['n'] => { Ok(::NumberingStyle::NumberForNone) }, ['p', rest..] => { - match regex::Regex::new(String::from_chars(rest).as_slice()) { + let s : String = rest.iter().map(|c| *c).collect(); + match regex::Regex::new(s.as_slice()) { Ok(re) => Ok(::NumberingStyle::NumberForRegularExpression(re)), Err(_) => Err(String::from_str("Illegal regular expression")), } diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 415e43571..3fe6ea9b2 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -8,14 +8,16 @@ * file that was distributed with this source code. * */ +#![feature(plugin)] -#[macro_use] extern crate regex_macros; +#[plugin] extern crate regex_macros; extern crate regex; extern crate getopts; use std::io::{stdin}; use std::io::BufferedReader; use std::io::fs::File; +use std::iter::repeat; use std::num::Int; use std::path::Path; use getopts::{optopt, optflag, getopts, usage, OptGroup}; @@ -282,7 +284,7 @@ fn nl (reader: &mut BufferedReader, settings: &Settings) { if settings.number_width > line_no_width { w = settings.number_width - line_no_width; } - let fill = String::from_char(w, fill_char); + let fill : String = repeat(fill_char).take(w).collect(); match settings.number_format { NumberFormat::Left => { println!("{1}{0}{2}{3}", fill, line_no, settings.number_separator, line)