Skip to content

Commit 1283caa

Browse files
committed
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.
1 parent 28e3340 commit 1283caa

File tree

3 files changed

+97
-64
lines changed

3 files changed

+97
-64
lines changed

src/libstd/path/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ use iter::Iterator;
7171
use option::{Option, None, Some};
7272
use str;
7373
use str::{MaybeOwned, Str, StrSlice, from_utf8_lossy};
74+
use strbuf::StrBuf;
7475
use slice::{OwnedCloneableVector, OwnedVector, Vector};
7576
use slice::{ImmutableEqVector, ImmutableVector};
7677
use vec::Vec;
@@ -528,6 +529,22 @@ impl BytesContainer for ~str {
528529
#[inline]
529530
fn is_str(_: Option<~str>) -> bool { true }
530531
}
532+
impl BytesContainer for StrBuf {
533+
#[inline]
534+
fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
535+
self.as_bytes()
536+
}
537+
#[inline]
538+
fn container_into_owned_bytes(self) -> Vec<u8> {
539+
self.into_bytes()
540+
}
541+
#[inline]
542+
fn container_as_str<'a>(&'a self) -> Option<&'a str> {
543+
Some(self.as_slice())
544+
}
545+
#[inline]
546+
fn is_str(_: Option<StrBuf>) -> bool { true }
547+
}
531548

532549
impl<'a> BytesContainer for &'a [u8] {
533550
#[inline]

0 commit comments

Comments
 (0)