144 Commits
Author SHA1 Message Date
d5c8ad3227 Release shared reference on zero truncate (#842)
Co-authored-by: JSap0914 <[email protected]>
2026-07-16 12:19:37 +02:00
vip892766gmaandGitHub 2256e6dc3e chore: add safety comments on unsafe blocks (#827) 2026-05-19 13:11:51 -04:00
Mai Thanh MinhandGitHub 00cc5ff2bd Implement BytesMut::extend_from_within (#818) 2026-02-03 15:33:17 +01:00
Alice Ryhl 5b79d316c9 Merge tag 'v1.11.1' 2026-02-03 13:45:19 +00:00
Alice RyhlandGitHub d0293b0e35 Merge commit from fork
* Add repro for integer overflow

Signed-off-by: Alice Ryhl <[email protected]>

* Always check overflow in new_cap + offset

Signed-off-by: Alice Ryhl <[email protected]>

---------

Signed-off-by: Alice Ryhl <[email protected]>
2026-02-03 14:40:22 +01:00
Alice RyhlandGitHub b4ed70daee Add test for copy_to_bytes() -> BytesMut avoiding clone (#809) 2025-12-02 13:08:19 +01:00
Paolo BarboliniandGitHub acd1e0ffb8 Fix get_int if nbytes is zero (#806) 2025-11-21 11:14:40 +01:00
discord9andGitHub 60cbb776f2 fix: BytesMut only reuse if src has remaining (#803)
Signed-off-by: discord9 <[email protected]>
2025-11-14 10:52:50 +01:00
Stepan KoltsovandGitHub ef7f25736c Specialize BytesMut::put::<Bytes> (#793) 2025-08-14 08:55:18 +00:00
Paolo BarboliniandGitHub 16132ad259 Fix latest clippy warnings (#787) 2025-07-16 10:53:50 +02:00
Paolo BarboliniandGitHub 3e44f88f5f Bump MSRV to 1.57 (#788) 2025-07-16 10:33:07 +02:00
Hange Shi - NJUandGitHub f29e93951d Add some tests for Limit, BytesMut and Reader (#785) 2025-05-28 12:56:41 +02:00
Michael FärberandGitHub d9d5c59ef8 Guarantee address in slice() for empty slices. (#780) 2025-05-20 14:52:05 +02:00
AbeZbm 5c90b11415 Add missing tests in test_bytes 2025-05-15 14:52:54 +08:00
venomousmoogandGitHub 36675436cc Fix memory leak in owned_to_vec (#773) 2025-03-05 10:44:40 +01:00
Taiki EndoandGitHub 71824b095c ci: test AArch64 and run tests instead of build in cross job (#763) 2025-01-27 10:58:12 +01:00
Alice RyhlandGitHub a1b1208127 Disable test_bytes_vec_alloc test on miri (#755) 2025-01-13 16:28:28 +01:00
aae4969fde Add specialized Buf::chunks_vectored for Take (#617)
Co-authored-by: Alice Ryhl <[email protected]>
Co-authored-by: Michal 'vorner' Vaner <[email protected]>
2025-01-13 12:53:52 +00:00
Paolo BarboliniandGitHub 16cc574fea Implement Buf::chunks_vectored for VecDeque<u8> (#708) 2025-01-10 14:40:12 +01:00
Paolo BarboliniandGitHub 0e9e4fc2f1 Expand Buf tests (#747) 2025-01-09 17:13:47 +01:00
Alice RyhlandGitHub f7072c9267 Run tests under panic=abort (#749) 2024-12-10 22:30:27 +01:00
Adam CimarostiandGitHub 30ee8e9cba Add Bytes::from_owner (#742) 2024-10-29 13:18:03 +01:00
Alice RyhlandGitHub 0ac54ca706 Guarantee address in split_off/split_to for empty slices (#740)
Signed-off-by: Alice Ryhl <[email protected]>
2024-10-18 19:46:49 +02:00
Paolo BarboliniandGitHub 79fb85323c fix: apply sign extension when decoding int (#732)
Closes #730
2024-08-30 08:20:29 -04:00
Cameron BythewayandGitHub ed7d5ff39e test: ensure BytesMut::advance reduces capacity (#728) 2024-08-02 19:07:45 +00:00
Alice Ryhl f8c7b574c0 Merge 'v1.6.1' into 'master' (#721) 2024-07-13 09:51:48 +02:00
Emily Crandall FleischmanandGitHub 6b4b0eda29 Fix Bytes::is_unique when created from shared BytesMut (#718)
The `is_unique` entry in the vtable for `Bytes` created from a shared
`BytesMut` just called the `shared_is_unique` function from the `bytes`
module. However, that function dereferences the `data` argument` as
`bytes::Shared`, but the actual underlying type is `bytes_mut::Shared`.
2024-07-13 01:09:46 +02:00
Sebastian HahnandGitHub 8cc940779f Allow reclaiming the current allocation (#686) 2024-06-28 14:26:32 +02:00
Anthony RamineandGitHub fa1daac3ae Change Bytes::make_mut to impl From<Bytes> for BytesMut (closes #709) (#710)
<Arc<T>>::make_mut returns a &mut T, such an API is doable for Bytes too
and thus we should reserve Bytes::make_mut for that.

Furthermore, it would be helpful to use From<Bytes> as a trait bound
in some cases with other traits such as Hyper's body trait, where Hyper
gives you Bytes values.

Finally, making it impl From<Bytes> for BytesMut means the API is more
easily discoverable as it appears on both Bytes and BytesMut.
2024-05-28 10:14:02 +02:00
Paolo BarboliniandGitHub caf520ac7f Fix iter tests to use the actual bytes IntoIter instead of std (#707) 2024-05-19 15:28:03 -04:00
Émile FugulinandGitHub 86694b0564 Add zero-copy make_mut (#695) 2024-05-05 17:58:00 +02:00
Brad DunbarandGitHub ca004117f8 Remove commented tests for Bytes::unsplit (#677)
Bytes doesn't have an unsplit method anymore. We can always retrieve
these from git history if necessary.
2024-03-04 09:05:00 +01:00
Brad DunbarandGitHub 7968f6f83d Remove redundant reserve call (#674) 2024-03-04 09:04:40 +01:00
Cyborus04andGitHub 0864aea970 add Bytes::is_unique (#643) 2024-01-19 23:59:30 +01:00
Alice RyhlandGitHub fd9243f9e2 Various cleanup (#635) 2023-10-02 15:40:02 +02:00
Taiki EndoandGitHub c7756c3e59 Fix CI failure (#616) 2023-06-05 01:04:59 +09:00
Michal NazarewiczandGitHub b29112ce44 Implement BufMut for &mut [MaybeUninit<u8>] (#597) 2023-02-10 10:28:24 +01:00
brian m. carlsonandGitHub 05e9d5cab9 Avoid large reallocations when freezing BytesMut (#592)
When we freeze a BytesMut, we turn it into a Vec, and then convert that
to a Bytes.  Currently, this happen using Vec::into_boxed_slice, which
reallocates to a slice of the same length as the Vev if the length and
the capacity are not equal.  This can pose a performance problem if the
Vec is large or if this happens many times in a loop.

Instead, let's compare the length and capacity, and if they're the same,
continue to handle this using into_boxed_slice.  Otherwise, since we
have a type of vtable which can handle a separate capacity, the shared
vtable, let's turn our Vec into that kind of Bytes.  While this does not
avoid allocation altogether, it performs a fixed size allocation and
avoids any need to memcpy.
2023-01-31 20:04:22 +01:00
Matt SchulteandGitHub d6e1999d97 Fix reserve over allocating underlying buffer (#560)
Fixes calls to `reserve` when the underlying shared buffer was already
big enough to fit the requested capacity. Previously a new even larger
buffer was created anyways. This could eventually lead to an OOM
condition.
2022-07-30 11:16:32 +02:00
cd188cbd67 Add conversion from Bytes to Vec<u8> (#547)
Signed-off-by: Jiahao XU <[email protected]>
Co-authored-by: Alice Ryhl <[email protected]>
2022-07-13 09:04:23 +02:00
Jiahao XUandGitHub 068ed41bc0 Add conversion from BytesMut to Vec<u8> (#543) 2022-07-10 12:44:29 +02:00
Alice RyhlandGitHub f514bd38da miri: don't use int2ptr casts for invalid pointers (#553) 2022-07-09 21:54:34 +02:00
Lucio FrancoandGitHub 28a1eab1e0 chore: Fix unused warnings (#551) 2022-06-23 09:16:03 -07:00
ZettrokeandGitHub 3536017ccf Fix chain remaining_mut(), allowing to chain growing buffer (#488) 2022-06-11 13:12:53 +09:00
Jiahao XUandGitHub 0a2c43af88 Fix bugs in BytesMut::reserve_inner (#544) 2022-04-28 11:37:33 +02:00
Jiahao XUandGitHub d4f5023383 Optimize BytesMut::reserve: Reuse vec if possible (#529)
* Optimize `BytesMut::reserve`: Reuse vec if possible

If the `BytesMut` holds a unqiue reference to `KIND_ARC` while the
capacity of the `Vec` is not big enough , reuse the existing `Vec`
instead of allocating a new one.

Signed-off-by: Jiahao XU <[email protected]>
2022-03-16 10:11:42 -04:00
Rob EdeandGitHub 131dae161f Implement Extend<Bytes> for BytesMut (#527) 2022-01-24 09:58:18 +01:00
Rob EdeandGitHub 0e3b2466f1 Address various clippy warnings (#528) 2022-01-24 09:58:05 +01:00
Noah KennedyandGitHub ba5c5c93af Appease miri (#515)
Rewrote the ledger in test_bytes_vec_alloc.rs to not piss off miri. The ledger is now a table within the allocator, which seems to satisfy miri. The old solution was to bundle an extra usize into the beginning of each allocation and then index past the start when deallocating data to get the size.
2021-11-07 10:23:12 -06:00
Ian JacksonandGitHub 0e9fa0b602 impl From<Box<[u8]>> for Bytes (#504) 2021-08-24 12:42:22 +02:00