Skip to content

Commit fcc8835

Browse files
committed
1 parent 7f9f976 commit fcc8835

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/mustache/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl<T: Iterator<char>> Compiler<T> {
6060

6161
match File::open(&path).read_to_end() {
6262
Ok(contents) => {
63-
let string = match str::from_utf8_owned(contents) {
64-
Some(string) => string,
63+
let string = match str::from_utf8(contents.as_slice()) {
64+
Some(string) => string.to_owned(),
6565
None => { fail!("Failed to parse file as UTF-8"); }
6666
};
6767

src/mustache/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Context {
101101
};
102102

103103
// TODO: maybe allow UTF-16 as well?
104-
let template = match str::from_utf8(s) {
104+
let template = match str::from_utf8(s.as_slice()) {
105105
Some(string) => string,
106106
None => { return Err(InvalidStr); }
107107
};

src/mustache/template.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'a> RenderContext<'a> {
159159
self.render_utag(&mut mem_wr, stack, path);
160160

161161
let bytes = mem_wr.unwrap();
162-
let s = str::from_utf8_owned(bytes).unwrap();
162+
let s = str::from_utf8(bytes.as_slice()).unwrap().to_owned();
163163

164164
for c in s.chars() {
165165
match c {
@@ -372,7 +372,7 @@ mod tests {
372372
let mut wr = MemWriter::new();
373373
try!(template.render(&mut wr, data));
374374

375-
Ok(str::from_utf8_owned(wr.unwrap()).unwrap())
375+
Ok(str::from_utf8(wr.unwrap().as_slice()).unwrap().to_owned())
376376
}
377377

378378
#[test]
@@ -403,7 +403,7 @@ mod tests {
403403
fn render_data<'a>(template: &Template, data: &Data<'a>) -> ~str {
404404
let mut wr = MemWriter::new();
405405
template.render_data(&mut wr, data);
406-
str::from_utf8_owned(wr.unwrap()).unwrap()
406+
str::from_utf8(wr.unwrap().as_slice()).unwrap().to_owned()
407407
}
408408
409409
#[test]
@@ -509,8 +509,8 @@ mod tests {
509509
Err(e) => fail!("Could not read file {}", e),
510510
};
511511

512-
let s = match str::from_utf8_owned(file_contents){
513-
Some(str) => str,
512+
let s = match str::from_utf8(file_contents.as_slice()){
513+
Some(str) => str.to_owned(),
514514
None => {fail!("File was not UTF8 encoded");}
515515
};
516516

0 commit comments

Comments
 (0)