Skip to content

Commit 19cc531

Browse files
committed
Fix for rustc compiler warnings (sample from playground)
``` warning: unused borrow that must be used --> src/main.rs:6:5 | 6 | &mut b[..].copy_from_slice(&src[..]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the borrow produces a value | = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 6 | let _ = &mut b[..].copy_from_slice(&src[..]); | +++++++ ```
1 parent ce26caf commit 19cc531

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packed_struct/src/types_generic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impl<T> PackedStructSlice for T where T: PackedStruct, T::ByteArray : ByteArray
77
return Err(PackingError::BufferSizeMismatch { expected: <T::ByteArray as ByteArray>::len(), actual: output.len() });
88
}
99
let packed = self.pack()?;
10-
&mut output[..].copy_from_slice(&packed.as_bytes_slice());
10+
output[..].copy_from_slice(&packed.as_bytes_slice());
1111
Ok(())
1212
}
1313

packed_struct_codegen/src/pack_codegen.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ fn pack_bits(field: &FieldRegular) -> PackBitsCopy {
162162

163163
PackBitsCopy {
164164
pack: quote! {
165-
&mut target[#start..#end].copy_from_slice(&packed);
165+
target[#start..#end].copy_from_slice(&packed);
166166
},
167167
unpack: quote! {
168168
let mut b = [0; (#end - #start)];
169-
&mut b[..].copy_from_slice(&src[#start..#end]);
169+
b[..].copy_from_slice(&src[#start..#end]);
170170
b
171171
}
172172
}

0 commit comments

Comments
 (0)