Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 7fa5383

Browse files
committed
Merge pull request #85 from Kintaro/index
Fixed Index trait and new PathBuf::new()
2 parents 5378f11 + db777e8 commit 7fa5383

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/json.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,17 +1148,17 @@ impl Json {
11481148
impl<'a> Index<&'a str> for Json {
11491149
type Output = Json;
11501150

1151-
fn index(&self, idx: & &str) -> &Json {
1152-
self.find(*idx).unwrap()
1151+
fn index(&self, idx: &str) -> &Json {
1152+
self.find(idx).unwrap()
11531153
}
11541154
}
11551155

11561156
impl Index<usize> for Json {
11571157
type Output = Json;
11581158

1159-
fn index<'a>(&'a self, idx: &usize) -> &'a Json {
1159+
fn index<'a>(&'a self, idx: usize) -> &'a Json {
11601160
match self {
1161-
&Json::Array(ref v) => &v[*idx],
1161+
&Json::Array(ref v) => &v[idx],
11621162
_ => panic!("can only index Json with usize if it is an array")
11631163
}
11641164
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Support code for encoding and decoding types.
1212
13-
#![feature(core, std_misc)]
13+
#![feature(core, convert)]
1414
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1515
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
1616
html_root_url = "http://doc.rust-lang.org/rustc-serialize/")]

src/serialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,14 @@ impl Decodable for path::PathBuf {
570570
use std::os::unix::prelude::*;
571571
let bytes: Vec<u8> = try!(Decodable::decode(d));
572572
let s: OsString = OsStringExt::from_vec(bytes);
573-
Ok(path::PathBuf::new(&s))
573+
Ok(path::PathBuf::from(s))
574574
}
575575
#[cfg(windows)]
576576
fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> {
577577
use std::os::windows::prelude::*;
578578
let bytes: Vec<u16> = try!(Decodable::decode(d));
579579
let s: OsString = OsStringExt::from_wide(&bytes);
580-
Ok(path::PathBuf::new(&s))
580+
Ok(path::PathBuf::from(s))
581581
}
582582
}
583583

0 commit comments

Comments
 (0)