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

Method read

examples/buffer_errors.rs:23–32  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

21 struct Wrapper<'a>(&'a mut [u8]);
22 impl<'a> Wrapper<'a> {
23 fn read(&mut self) {
24 // Ideally we'd write this, but it gets:
25 // "cannot move out of `self` which is behind a mutable reference".
26 /*
27 read(self.0);
28 */
29
30 // The fix: add `&mut *`.
31 read(&mut *self.0);
32 }
33 }
34 let mut buf = vec![0_u8; 3];
35 let mut wrapper = Wrapper(&mut buf);

Callers 2

mainFunction · 0.45
error_buffer_wrapperFunction · 0.45

Calls 1

readFunction · 0.70

Tested by

no test coverage detected