about summary refs log tree commit diff
path: root/src/libserialize
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-26 21:00:43 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-03-04 15:59:30 -0800
commit95d904625b4d45af80b4e40d51a3a0fde1abaa8a (patch)
treeb0872e63b8d75543ce5141ceba44c12c459474f2 /src/libserialize
parent3b3bb0e682c2d252e9f62dd9df5cff9552af91ad (diff)
downloadrust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.tar.gz
rust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.zip
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.
Diffstat (limited to 'src/libserialize')
-rw-r--r--src/libserialize/lib.rs1
-rw-r--r--src/libserialize/serialize.rs14
2 files changed, 15 insertions, 0 deletions
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<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
+        self.to_str().unwrap().encode(e)
+    }
+}
+
+impl Decodable for path::PathBuf {
+    fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> {
+        let bytes: String = try!(Decodable::decode(d));
+        Ok(path::PathBuf::new(&bytes))
+    }
+}
+
 impl<T: Encodable + Copy> Encodable for Cell<T> {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         self.get().encode(s)