-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Implement everything for 0.5 #210
[WIP] Implement everything for 0.5 #210
Conversation
…Mut, refactor iterators
Thanks for taking this on!
|
@seanmonstar, you mentioned in Is this design acceptable? |
@YetAnotherMinion I think |
@seanmonstar They do implement Apply this patch to this PR branch to see it working. diff --git a/tests/test_chain.rs b/tests/test_chain.rs
index 8877258..42a16eb 100644
--- a/tests/test_chain.rs
+++ b/tests/test_chain.rs
@@ -48,6 +48,15 @@ fn iterating_two_bufs() {
}
#[test]
+fn dirty_hack() {
+ let mut a = BytesMut::from(&b"hello"[..]);
+ let b = Bytes::from(&b"world"[..]);
+ a.extend(b);
+
+ assert_eq!(a.bytes(), &b"helloworld"[..]);
+}
+
+#[test]
fn vectored_read() {
let a = Cursor::new(Bytes::from(&b"hello"[..]));
let b = Cursor::new(Bytes::from(&b"world"[..])); |
Oh OK, I get it! That's probably good then. |
… Bytes from slice
Predicts the size of the buffer that will be created by calling
Is this really a good idea? |
@arthurprs see #139 for justification. Additionally, I would not worry about this PR, it has been 5 months with no activity which means there is no business value in these proposed changes. |
While I understand the reasoning this severely limits Byte as a Vec replacement, like backing a https://crates.io/crates/string |
@YetAnotherMinion Sorry for the radio silence, it was not cool on my part to drop the ball. This PR is great work and very helpful. The 0.5 release delay is mostly due to an attempt to coordinate a release with Tokio 0.2 release. Tokio includes 0.5 represents a cleanup pass and, as such, doesn't really have a reason to ship on its own. Once Tokio 0.2 gets closer (which I hope to start tracking better), we can revive this PR. |
Sorry for it taking so long, we're now actively working on 0.5 things. I've started splitting this PR into specific features, such as #260. I'll close once all have been merged. |
Hey, thanks for picking this stuff up again. I ended up using a private fork at work and moved on. It will be nice to switch back over coming soon. If there are still some other issues for 0.5 that need help, I am happy to pitch in. |
We've released 0.5! |
I am working off of the list of issues under 0.5 milestone.
This should address: #158, #75, #139, #196, #74
Changelog
Renames the
Buf::take
method toBuf::limit
to better describe what that method does. The rename was necessary to prevent ambiguity withBytesMut::take
. I renamedTake
toLimit
to match the constructor method name.Removed
Buf
impl for Cursor and replaced it withimpl Buf for Bytes
Removed
Buf
impl forCursor<BytesMut>
and replaced it withimpl Buf for BytesMut
Renamed
Iter
toIntoIter
to match naming convention of rust where iterators that move the collection are namedIntoIter
Adds
impl<T: Buf> IntoIterator for T
that constructs abytes::buf::IntoIter
struct.Removs
iter
method fromBuf
trait. The existing behavior with respect to ownership matched the convention ofinto_iter
instead ofiter
. The builtinIntoIterator
trait already provides forinto_iter
, so I decided to avoid ambiguity by just removingBuf::iter
instead of a rename. It is up to each container implementing Buf to implementiter
efficiently if possible.Adds
Bytes::iter
which returnsslice::Iter
.Adds
BytesMut::iter
which returnsslice::Iter
.Adds
Bytes::copy_from_slice(src: &'a [u8])
which constructs a newRemoved
impl<'a> From<&'a [u8]> for Bytes
and replaced withimpl From<&'static [u8]> for Bytes
which does not copy the data.Adds
IntoBuf::len
which returns the size of the buffer that would be created by callinginto_buf()
onself
.