Skip to content

Commit c417012

Browse files
refactor: add deref_by_slicing clippy style and readability lint (#979)
> Checks for slicing expressions which are equivalent to dereferencing the value. > Some people may prefer to dereference rather than slice.
1 parent 42fbd5f commit c417012

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ semicolon_outside_block = "warn" # With semicolon-outside-block-ignore-multiline
121121
clone_on_ref_ptr = "warn"
122122
cloned_instead_of_copied = "warn"
123123
pub_without_shorthand = "warn"
124+
deref_by_slicing = "warn"
124125
multiple_inherent_impl = "warn"
125126
map_with_unused_argument_over_ranges = "warn"
126127
trait_duplication_in_bounds = "warn"

crates/ironrdp-testsuite-core/tests/graphics/rlgr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn encode_works_with_rlgr3() {
1919
let output_len = expected.len();
2020
let mut output = vec![0u8; output_len];
2121
encode(mode, input, &mut output).unwrap();
22-
assert_eq!(&expected[..], &output[..]);
22+
assert_eq!(*expected, &output);
2323
}
2424
}
2525

@@ -41,7 +41,7 @@ fn decode_works_with_rlgr3() {
4141
let mut output = vec![0i16; expected.len() * output_len];
4242
for (i, (input, expected)) in input.iter().zip(expected.iter()).enumerate() {
4343
decode(mode, input, &mut output[i * output_len..(i + 1) * output_len]).unwrap();
44-
assert_eq!(&expected[..], &output[i * 4096..(i + 1) * 4096]);
44+
assert_eq!(**expected, output[i * 4096..(i + 1) * 4096]);
4545
}
4646
}
4747

crates/ironrdp-testsuite-core/tests/pdu/pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn expect_pointer_png(pointer: &DecodedPointer, expected_file_path: &str) {
2929
}
3030

3131
let png_buffer = std::fs::read(path).unwrap();
32-
let mut png_reader = png::Decoder::new(Cursor::new(&png_buffer[..])).read_info().unwrap();
32+
let mut png_reader = png::Decoder::new(Cursor::new(&png_buffer)).read_info().unwrap();
3333
let mut png_reader_buffer = vec![0u8; png_reader.output_buffer_size().unwrap()];
3434
let frame_size = png_reader.next_frame(&mut png_reader_buffer).unwrap().buffer_size();
3535
let expected = &png_reader_buffer[..frame_size];

crates/ironrdp-web/src/network_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl AsyncNetworkClient for WasmNetworkClient {
2020

2121
match &network_request.protocol {
2222
NetworkProtocol::Http | NetworkProtocol::Https => {
23-
let body = js_sys::Uint8Array::from(&network_request.data[..]);
23+
let body = js_sys::Uint8Array::from(network_request.data.as_slice());
2424

2525
let response = gloo_net::http::Request::post(network_request.url.as_str())
2626
.header("keep-alive", "true")

0 commit comments

Comments
 (0)