| 152 | } |
| 153 | |
| 154 | fn error_array_by_value() { |
| 155 | use rustix::buffer::Buffer; |
| 156 | |
| 157 | fn read<B: Buffer<u8>>(b: B) -> B::Output { |
| 158 | unsafe { b.assume_init(0) } |
| 159 | } |
| 160 | |
| 161 | // This code is erroneously attempts to pass a buffer by value, but it |
| 162 | // confusingly gets two error messages: |
| 163 | // "the trait bound `[{integer}; 3]: Buffer<u8>` is not satisfied", and |
| 164 | // "the trait bound `[{integer}; 3]: buffer::private::Sealed<u8>` is not satisfied". |
| 165 | /* |
| 166 | let mut buf = [0, 0, 0]; |
| 167 | read(buf); |
| 168 | */ |
| 169 | |
| 170 | // The fix: pass the buffer by reference. |
| 171 | let mut buf = [0, 0, 0]; |
| 172 | read(&mut buf); |
| 173 | } |