mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-15 00:00:18 +02:00
Track Rust nightlies
This commit is contained in:
+6
-6
@@ -86,12 +86,12 @@ impl ToBytes for SeqByteStr {
|
||||
impl ops::Index<usize> for SeqByteStr {
|
||||
type Output = u8;
|
||||
|
||||
fn index(&self, index: &usize) -> &u8 {
|
||||
assert!(*index < self.len());
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
assert!(index < self.len());
|
||||
|
||||
unsafe {
|
||||
&*self.mem.ptr()
|
||||
.offset(*index as isize + self.pos as isize)
|
||||
.offset(index as isize + self.pos as isize)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,9 +187,9 @@ impl ToBytes for SmallByteStr {
|
||||
impl ops::Index<usize> for SmallByteStr {
|
||||
type Output = u8;
|
||||
|
||||
fn index(&self, index: &usize) -> &u8 {
|
||||
assert!(*index < self.len());
|
||||
&self.bytes[*index]
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
assert!(index < self.len());
|
||||
&self.bytes[index]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -163,7 +163,7 @@ impl ToBytes for Bytes {
|
||||
impl ops::Index<usize> for Bytes {
|
||||
type Output = u8;
|
||||
|
||||
fn index(&self, index: &usize) -> &u8 {
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
self.obj().index(index)
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ trait ByteStrPriv {
|
||||
|
||||
fn get_type_id(&self) -> TypeId;
|
||||
|
||||
fn index(&self, index: &usize) -> &u8;
|
||||
fn index(&self, index: usize) -> &u8;
|
||||
|
||||
fn len(&self) -> usize;
|
||||
|
||||
@@ -245,7 +245,7 @@ impl<B: ByteStr + 'static> ByteStrPriv for B {
|
||||
Any::get_type_id(self)
|
||||
}
|
||||
|
||||
fn index(&self, index: &usize) -> &u8 {
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
ops::Index::index(self, index)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#![crate_name = "bytes"]
|
||||
#![unstable]
|
||||
|
||||
#![feature(alloc, core, unsafe_no_drop_flag)]
|
||||
#![feature(alloc, convert, core, unsafe_no_drop_flag)]
|
||||
|
||||
pub use byte_buf::{ByteBuf, ROByteBuf, MutByteBuf};
|
||||
pub use byte_str::{SeqByteStr, SmallByteStr, SmallByteStrBuf};
|
||||
@@ -314,7 +314,7 @@ impl<'a> ToBytes for &'a [u8] {
|
||||
|
||||
impl<'a> ToBytes for &'a Vec<u8> {
|
||||
fn to_bytes(self) -> Bytes {
|
||||
self.as_slice().to_bytes()
|
||||
(&self[..]).to_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ impl<'a> Source for &'a Vec<u8> {
|
||||
type Error = BufError;
|
||||
|
||||
fn fill<B: MutBuf>(self, buf: &mut B) -> Result<usize, BufError> {
|
||||
Ok(buf.write_slice(self.as_slice()))
|
||||
Ok(buf.write_slice(self.as_ref()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -157,15 +157,15 @@ impl ToBytes for Rope {
|
||||
impl ops::Index<usize> for Rope {
|
||||
type Output = u8;
|
||||
|
||||
fn index(&self, index: &usize) -> &u8 {
|
||||
assert!(*index < self.len());
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
assert!(index < self.len());
|
||||
|
||||
let left_len = self.inner.left.len();
|
||||
|
||||
if *index < left_len {
|
||||
if index < left_len {
|
||||
self.inner.left.index(index)
|
||||
} else {
|
||||
self.inner.right.index(&(*index - left_len))
|
||||
self.inner.right.index(index - left_len)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,7 +556,7 @@ impl Balance {
|
||||
}
|
||||
|
||||
fn peek(&self) -> Option<&Bytes> {
|
||||
self.stack.as_slice().last()
|
||||
self.stack.last()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user