@calebccff @firstname.lastname@example.org When starting Rust, it took me a while to understand how slices worked. As someone who worked a bit with C and C++ before, seeing the data layout on https://cheats.rs/#references-pointers-ui helped - a "regular slice reference" shown there is just a ptr and a len. And lower down the page in "Standard Library Types", a Vec is just a ptr, capacity and len. And it reveals how a slice can be got easily from a Vec just by taking the Vec's ptr and len, and passing them to another function.
@calebccff @email@example.com What gets passed to poll() is a "slice", which consists of a pointer to some memory where a number of elements are stored sequentially, and a count of how many elements are there, and that's all poll() needs to work with.
A slice isn't quite the same as an array, slices don't own memory, they refer to memory "elsewhere" (in this case, memory owned by the Vec). IME arrays aren't used very much in Rust, due to the size-known-at-compile thing. Vec and slices are used instead.
@calebccff @firstname.lastname@example.org If referring to https://docs.rs/nix/0.23.0/nix/poll/fn.poll.html looks like this does take a slice of PollFds, so it should be possible to have a Vec<PollFd> and pass a slice of it by e.g. `poll(&mut my_vec, my_timeout)`. Here's a similar example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ab632fa07cd5cf3decc28bac6f0e4673
@friend haha yeah I did suspect this was against at least the spirit of the law, and it seems against the letter of the law too
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!