Skip to content

Commit 7f23055

Browse files
authored
Document the behavior change of passing a &mut Vec. (#1358)
Passing a `&mut Vec<_>` to `epoll::wait` or `kqeue::kevent` unfortunately gets silently different behavior compared to 0.38, so document it accordingly. And some minor tidying in CHANGES.md.
1 parent a768523 commit 7f23055

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

CHANGES.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
# Changes from 0.38.x to 1.0
1+
# Changes from 0.38.x to 1.x
22

3-
## Behavior changes
3+
## Silent behavior changes
44

55
[`rustix::pipe::fcntl_setpipe_size`] now returns the new size, which may be
66
greater than the requested size.
77

88
[`rustix::pipe::fcntl_setpipe_size`]: https://docs.rs/rustix/1.0.0/rustix/pipe/fn.fcntl_setpipe_size.html
99

10+
When a `&mut Vec<_>` is passed to [`rustix::event::epoll::wait`] or
11+
[`rustix::event::kqueue::kevent`], these functions previously adjusted the
12+
length of the `Vec` to the number of elements written, and now do not. A common
13+
alternative is to wrap the `&mut Vec<_>` using [`spare_capacity`], and then to
14+
clear the `Vec` by iterating using `.drain(..)` after each call. For an example
15+
of using `spare_capacity` in this way, see [here].
16+
17+
[`rustix::event::epoll::wait`]: https://docs.rs/rustix/1.0.0/rustix/event/epoll/fn.wait.html
18+
[`rustix::event::kqueue::kevent`]: https://docs.rs/rustix/1.0.0/x86_64-unknown-freebsd/rustix/event/kqueue/fn.kqueue.html
19+
[`spare_capacity`]: https://docs.rs/rustix/1.0.0/rustix/buffer/fn.spare_capacity.html
20+
[here]: https://docs.rs/rustix/1.0.0/rustix/event/epoll/index.html#examples
21+
1022
## API changes
1123

1224
`rustix::thread::FutexOperation` and `rustix::thread::futex` are removed. Use
@@ -53,11 +65,12 @@ the capitalization), for consistency with [`rustix::process::WaitId`].
5365
[`rustix::process::WaitId`]: https://docs.rs/rustix/1.0.0/rustix/process/enum.WaitId.html
5466

5567
The offsets in [`rustix::fs::SeekFrom::Hole`] and
56-
[`rustix::fs::SeekFrom::Data`] are changed from `i64` to `u64` since they
57-
represent absolute offsets.
68+
[`rustix::fs::SeekFrom::Data`] are changed from `i64` to `u64`, to
69+
[align with std], since they represent absolute offsets.
5870

5971
[`rustix::fs::SeekFrom::Hole`]: https://docs.rs/rustix/1.0.0/rustix/fs/enum.SeekFrom.html#variant.Hole
6072
[`rustix::fs::SeekFrom::Data`]: https://docs.rs/rustix/1.0.0/rustix/fs/enum.SeekFrom.html#variant.Data
73+
[align with std]: https://doc.rust-lang.org/stable/std/io/enum.SeekFrom.html#variant.Start
6174

6275
Functions in [`rustix::net::sockopt`] are renamed to remove the `get_` prefix,
6376
to [align with Rust conventions].

0 commit comments

Comments
 (0)