MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / error_empty_slice

Function error_empty_slice

examples/buffer_errors.rs:138–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136}
137
138fn error_empty_slice() {
139 use rustix::buffer::Buffer;
140
141 fn read<B: Buffer<u8>>(_: B) {}
142
143 // Functions that take `&mut [u8]` can be passed `&mut []`, but with
144 // `Buffer` passing `&mut []` gets:
145 // "type annotations needed".
146 /*
147 read(&mut []);
148 */
149
150 // The fix: make the element type explicit.
151 read(&mut [0_u8; 0]);
152}
153
154fn error_array_by_value() {
155 use rustix::buffer::Buffer;

Callers 1

mainFunction · 0.85

Calls 1

readFunction · 0.70

Tested by

no test coverage detected