Skip to content

Commit 122c94d

Browse files
committed
Implement BytesContainer for MaybeOwned
1 parent 28467f5 commit 122c94d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libstd/path/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,23 @@ impl BytesContainer for CString {
591591
}
592592
}
593593

594+
impl<'a> BytesContainer for str::MaybeOwned<'a> {
595+
#[inline]
596+
fn container_as_bytes<'b>(&'b self) -> &'b [u8] {
597+
self.as_slice().as_bytes()
598+
}
599+
#[inline]
600+
fn container_into_owned_bytes(self) -> ~[u8] {
601+
self.into_owned().into_bytes()
602+
}
603+
#[inline]
604+
fn container_as_str<'b>(&'b self) -> Option<&'b str> {
605+
Some(self.as_slice())
606+
}
607+
#[inline]
608+
fn is_str(_: Option<str::MaybeOwned>) -> bool { true }
609+
}
610+
594611
#[inline(always)]
595612
fn contains_nul(v: &[u8]) -> bool {
596613
v.iter().any(|&x| x == 0)

0 commit comments

Comments
 (0)