diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-12 22:44:31 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-12 22:51:11 +1000 |
| commit | 1283caa8cb937eed6829a71c93470224e55a1fca (patch) | |
| tree | 0cc632a2731a1ab3117feebe9d3243784b06cd78 /src/libstd/path/mod.rs | |
| parent | 28e3340a078bfb53fd621900fb17d42d6e718526 (diff) | |
std: migrate path::windows to using StrBuf internally.
Same representation change performed with path::unix. This also implements BytesContainer for StrBuf & adds an (unsafe) method for viewing & mutating the raw byte vector of a StrBuf.
Diffstat (limited to 'src/libstd/path/mod.rs')
| -rw-r--r-- | src/libstd/path/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 72cbdccddc0..88be22901a4 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -71,6 +71,7 @@ use iter::Iterator; use option::{Option, None, Some}; use str; use str::{MaybeOwned, Str, StrSlice, from_utf8_lossy}; +use strbuf::StrBuf; use slice::{OwnedCloneableVector, OwnedVector, Vector}; use slice::{ImmutableEqVector, ImmutableVector}; use vec::Vec; @@ -528,6 +529,22 @@ impl BytesContainer for ~str { #[inline] fn is_str(_: Option<~str>) -> bool { true } } +impl BytesContainer for StrBuf { + #[inline] + fn container_as_bytes<'a>(&'a self) -> &'a [u8] { + self.as_bytes() + } + #[inline] + fn container_into_owned_bytes(self) -> Vec<u8> { + self.into_bytes() + } + #[inline] + fn container_as_str<'a>(&'a self) -> Option<&'a str> { + Some(self.as_slice()) + } + #[inline] + fn is_str(_: Option<StrBuf>) -> bool { true } +} impl<'a> BytesContainer for &'a [u8] { #[inline] |
