Skip to content

Commit 23fe16e

Browse files
committed
rustbook: update slicing syntax where [] --> [..]
1 parent dcc6ce2 commit 23fe16e

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/rustbook/book.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ impl<'a> Iterator for BookItems<'a> {
5050

5151
let mut section = "".to_string();
5252
for &(_, idx) in &self.stack {
53-
section.push_str(&(idx + 1).to_string()[]);
53+
section.push_str(&(idx + 1).to_string()[..]);
5454
section.push('.');
5555
}
56-
section.push_str(&(self.cur_idx + 1).to_string()[]);
56+
section.push_str(&(self.cur_idx + 1).to_string()[..]);
5757
section.push('.');
5858

5959
self.stack.push((self.cur_items, self.cur_idx));
60-
self.cur_items = &cur.children[];
60+
self.cur_items = &cur.children[..];
6161
self.cur_idx = 0;
6262
return Some((section, cur))
6363
}
@@ -68,7 +68,7 @@ impl<'a> Iterator for BookItems<'a> {
6868
impl Book {
6969
pub fn iter(&self) -> BookItems {
7070
BookItems {
71-
cur_items: &self.chapters[],
71+
cur_items: &self.chapters[..],
7272
cur_idx: 0,
7373
stack: Vec::new(),
7474
}

src/rustbook/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn write_toc(book: &Book, path_to_root: &Path, out: &mut Writer) -> IoResult<()>
4141
path_to_root: &Path,
4242
out: &mut Writer) -> IoResult<()> {
4343
for (i, item) in items.iter().enumerate() {
44-
try!(walk_item(item, &format!("{}{}.", section, i + 1)[], path_to_root, out));
44+
try!(walk_item(item, &format!("{}{}.", section, i + 1)[..], path_to_root, out));
4545
}
4646
Ok(())
4747
}
@@ -55,7 +55,7 @@ fn write_toc(book: &Book, path_to_root: &Path, out: &mut Writer) -> IoResult<()>
5555
item.title));
5656
if !item.children.is_empty() {
5757
try!(writeln!(out, "<ul class='section'>"));
58-
let _ = walk_items(&item.children[], section, path_to_root, out);
58+
let _ = walk_items(&item.children[..], section, path_to_root, out);
5959
try!(writeln!(out, "</ul>"));
6060
}
6161
try!(writeln!(out, "</li>"));
@@ -65,7 +65,7 @@ fn write_toc(book: &Book, path_to_root: &Path, out: &mut Writer) -> IoResult<()>
6565

6666
try!(writeln!(out, "<div id='toc' class='mobile-hidden'>"));
6767
try!(writeln!(out, "<ul class='chapter'>"));
68-
try!(walk_items(&book.chapters[], "", path_to_root, out));
68+
try!(walk_items(&book.chapters[..], "", path_to_root, out));
6969
try!(writeln!(out, "</ul>"));
7070
try!(writeln!(out, "</div>"));
7171

@@ -179,7 +179,7 @@ impl Subcommand for Build {
179179
Err(errors) => {
180180
let n = errors.len();
181181
for err in errors {
182-
term.err(&format!("error: {}", err)[]);
182+
term.err(&format!("error: {}", err)[..]);
183183
}
184184

185185
Err(box format!("{} errors occurred", n) as Box<Error>)

src/rustbook/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ fn main() {
5454
if cmd.len() <= 1 {
5555
help::usage()
5656
} else {
57-
match subcommand::parse_name(&cmd[1][]) {
57+
match subcommand::parse_name(&cmd[1][..]) {
5858
Some(mut subcmd) => {
5959
match subcmd.parse_args(cmd.tail()) {
6060
Ok(_) => {
6161
match subcmd.execute(&mut term) {
6262
Ok(_) => (),
6363
Err(err) => {
64-
term.err(&format!("error: {}", err.description())[]);
64+
term.err(&format!("error: {}", err.description())[..]);
6565
err.detail().map(|detail| {
66-
term.err(&format!("detail: {}", detail)[]);
66+
term.err(&format!("detail: {}", detail)[..]);
6767
});
6868
}
6969
}

src/rustbook/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ impl Subcommand for Test {
5050
Ok(output) => {
5151
if !output.status.success() {
5252
term.err(&format!("{}\n{}",
53-
String::from_utf8_lossy(&output.output[]),
54-
String::from_utf8_lossy(&output.error[]))[]);
53+
String::from_utf8_lossy(&output.output[..]),
54+
String::from_utf8_lossy(&output.error[..]))[..]);
5555
return Err(box "Some tests failed." as Box<Error>);
5656
}
5757

0 commit comments

Comments
 (0)