diff options
Diffstat (limited to 'src/libserialize')
| -rw-r--r-- | src/libserialize/lib.rs | 1 | ||||
| -rw-r--r-- | src/libserialize/serialize.rs | 14 |
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) |
