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

Fixed Index trait and new PathBuf::new() #85

Merged
merged 2 commits into from
Mar 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,17 +1148,17 @@ impl Json {
impl<'a> Index<&'a str> for Json {
type Output = Json;

fn index(&self, idx: & &str) -> &Json {
self.find(*idx).unwrap()
fn index(&self, idx: &str) -> &Json {
self.find(idx).unwrap()
}
}

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

fn index<'a>(&'a self, idx: &usize) -> &'a Json {
fn index<'a>(&'a self, idx: usize) -> &'a Json {
match self {
&Json::Array(ref v) => &v[*idx],
&Json::Array(ref v) => &v[idx],
_ => panic!("can only index Json with usize if it is an array")
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Support code for encoding and decoding types.

#![feature(core, std_misc)]
#![feature(core, convert)]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/rustc-serialize/")]
Expand Down
4 changes: 2 additions & 2 deletions src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,14 @@ impl Decodable for path::PathBuf {
use std::os::unix::prelude::*;
let bytes: Vec<u8> = try!(Decodable::decode(d));
let s: OsString = OsStringExt::from_vec(bytes);
Ok(path::PathBuf::new(&s))
Ok(path::PathBuf::from(s))
}
#[cfg(windows)]
fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> {
use std::os::windows::prelude::*;
let bytes: Vec<u16> = try!(Decodable::decode(d));
let s: OsString = OsStringExt::from_wide(&bytes);
Ok(path::PathBuf::new(&s))
Ok(path::PathBuf::from(s))
}
}

Expand Down