Skip to content

Commit

Permalink
std: migrate path::windows to using StrBuf internally.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
huonw committed Apr 12, 2014
1 parent 28e3340 commit 1283caa
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 64 deletions.
17 changes: 17 additions & 0 deletions src/libstd/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down
Loading

0 comments on commit 1283caa

Please sign in to comment.