Skip to content

Commit db777e8

Browse files
committed
changed to PathBuf::from and added convert feature
1 parent 256e41b commit db777e8

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

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)]
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +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-
let mut p = path::PathBuf::new();
574-
p.push(s);
575-
Ok(p)
573+
Ok(path::PathBuf::from(s))
576574
}
577575
#[cfg(windows)]
578576
fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> {
579577
use std::os::windows::prelude::*;
580578
let bytes: Vec<u16> = try!(Decodable::decode(d));
581579
let s: OsString = OsStringExt::from_wide(&bytes);
582-
let mut p = PathBuf::new();
583-
p.push(s);
584-
Ok(p)
580+
Ok(path::PathBuf::from(s))
585581
}
586582
}
587583

0 commit comments

Comments
 (0)