Fallout of std::str stabilization

This commit is contained in:
Alex Crichton 2014-12-10 19:46:38 -08:00
parent 4908017d59
commit 082bfde412
193 changed files with 2143 additions and 2230 deletions

View file

@ -36,7 +36,7 @@ impl ExternalHtml {
pub fn load_string(input: &Path) -> io::IoResult<Option<String>> {
let mut f = try!(io::File::open(input));
let d = try!(f.read_to_end());
Ok(str::from_utf8(d.as_slice()).map(|s| s.to_string()))
Ok(str::from_utf8(d.as_slice()).map(|s| s.to_string()).ok())
}
macro_rules! load_or_return {

View file

@ -16,7 +16,7 @@
//! them in the future to instead emit any format desired.
use std::fmt;
use std::string::String;
use std::iter::repeat;
use syntax::ast;
use syntax::ast_util;
@ -198,12 +198,12 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
path(w, p, print_all,
|cache, loc| {
if ast_util::is_local(did) || cache.inlined.contains(&did) {
Some(("../".repeat(loc.len())).to_string())
Some(repeat("../").take(loc.len()).collect::<String>())
} else {
match cache.extern_locations[did.krate] {
render::Remote(ref s) => Some(s.to_string()),
render::Local => {
Some(("../".repeat(loc.len())).to_string())
Some(repeat("../").take(loc.len()).collect::<String>())
}
render::Unknown => None,
}
@ -324,7 +324,7 @@ fn primitive_link(f: &mut fmt::Formatter,
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
let len = if len == 0 {0} else {len - 1};
try!(write!(f, "<a href='{}primitive.{}.html'>",
"../".repeat(len),
repeat("../").take(len).collect::<String>(),
prim.to_url_str()));
needs_termination = true;
}
@ -337,7 +337,7 @@ fn primitive_link(f: &mut fmt::Formatter,
render::Remote(ref s) => Some(s.to_string()),
render::Local => {
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
Some("../".repeat(len))
Some(repeat("../").take(len).collect::<String>())
}
render::Unknown => None,
};

View file

@ -34,7 +34,7 @@ pub fn highlight(src: &str, class: Option<&str>, id: Option<&str>) -> String {
class,
id,
&mut out).unwrap();
String::from_utf8_lossy(out[]).into_string()
String::from_utf8_lossy(out[]).into_owned()
}
/// Exhausts the `lexer` writing the output into `out`.

View file

@ -42,8 +42,8 @@ use std::fmt;
use std::io::fs::PathExtensions;
use std::io::{fs, File, BufferedWriter, BufferedReader};
use std::io;
use std::iter::repeat;
use std::str;
use std::string::String;
use std::sync::Arc;
use externalfiles::ExternalHtml;
@ -1186,7 +1186,8 @@ impl Context {
&Sidebar{ cx: cx, item: it },
&Item{ cx: cx, item: it }));
} else {
let mut url = "../".repeat(cx.current.len());
let mut url = repeat("../").take(cx.current.len())
.collect::<String>();
match cache().paths.get(&it.def_id) {
Some(&(ref names, _)) => {
for name in names[..names.len() - 1].iter() {
@ -1382,7 +1383,8 @@ impl<'a> fmt::Show for Item<'a> {
let amt = if self.ismodule() { cur.len() - 1 } else { cur.len() };
for (i, component) in cur.iter().enumerate().take(amt) {
try!(write!(fmt, "<a href='{}index.html'>{}</a>::<wbr>",
"../".repeat(cur.len() - i - 1),
repeat("../").take(cur.len() - i - 1)
.collect::<String>(),
component.as_slice()));
}
}

View file

@ -319,7 +319,7 @@ pub fn unindent(s: &str) -> String {
let ignore_previous_indents =
saw_first_line &&
!saw_second_line &&
!line.is_whitespace();
!line.chars().all(|c| c.is_whitespace());
let min_indent = if ignore_previous_indents {
uint::MAX
@ -331,7 +331,7 @@ pub fn unindent(s: &str) -> String {
saw_second_line = true;
}
if line.is_whitespace() {
if line.chars().all(|c| c.is_whitespace()) {
min_indent
} else {
saw_first_line = true;
@ -353,7 +353,7 @@ pub fn unindent(s: &str) -> String {
if lines.len() >= 1 {
let mut unindented = vec![ lines[0].trim().to_string() ];
unindented.push_all(lines.tail().iter().map(|&line| {
if line.is_whitespace() {
if line.chars().all(|c| c.is_whitespace()) {
line.to_string()
} else {
assert!(line.len() >= min_indent);