From 95d904625b4d45af80b4e40d51a3a0fde1abaa8a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Feb 2015 21:00:43 -0800 Subject: std: Deprecate std::old_io::fs This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change. --- src/libserialize/lib.rs | 1 + src/libserialize/serialize.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'src/libserialize') diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index d476fd72abc..bfc6b1bf0ef 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -35,6 +35,7 @@ Core encoding and decoding interfaces. #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] +#![feature(path)] #![cfg_attr(test, feature(test))] // test harness access diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 70f0ba4bb23..f287229e083 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -15,6 +15,7 @@ Core encoding and decoding interfaces. */ use std::old_path; +use std::path; use std::rc::Rc; use std::cell::{Cell, RefCell}; use std::sync::Arc; @@ -564,6 +565,19 @@ impl Decodable for old_path::windows::Path { } } +impl Encodable for path::PathBuf { + fn encode(&self, e: &mut S) -> Result<(), S::Error> { + self.to_str().unwrap().encode(e) + } +} + +impl Decodable for path::PathBuf { + fn decode(d: &mut D) -> Result { + let bytes: String = try!(Decodable::decode(d)); + Ok(path::PathBuf::new(&bytes)) + } +} + impl Encodable for Cell { fn encode(&self, s: &mut S) -> Result<(), S::Error> { self.get().encode(s) -- cgit 1.4.1-3-g733a5