提交 122c94d2 编写于 作者: K Kevin Ballard

Implement BytesContainer for MaybeOwned

上级 28467f5d
......@@ -591,6 +591,23 @@ fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
}
}
impl<'a> BytesContainer for str::MaybeOwned<'a> {
#[inline]
fn container_as_bytes<'b>(&'b self) -> &'b [u8] {
self.as_slice().as_bytes()
}
#[inline]
fn container_into_owned_bytes(self) -> ~[u8] {
self.into_owned().into_bytes()
}
#[inline]
fn container_as_str<'b>(&'b self) -> Option<&'b str> {
Some(self.as_slice())
}
#[inline]
fn is_str(_: Option<str::MaybeOwned>) -> bool { true }
}
#[inline(always)]
fn contains_nul(v: &[u8]) -> bool {
v.iter().any(|&x| x == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册