From a14f4052cfd746093cf4266f681d489f03e13399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20ROUDNINSKI?= Date: Tue, 23 Nov 2021 16:46:56 +0000 Subject: [PATCH] rust: remove needless borrow (#6922) This was discovered by running clippy. --- rust/flatbuffers/src/get_root.rs | 4 ++-- rust/flatbuffers/src/vector.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/flatbuffers/src/get_root.rs b/rust/flatbuffers/src/get_root.rs index 2a01cf87e..3305efade 100644 --- a/rust/flatbuffers/src/get_root.rs +++ b/rust/flatbuffers/src/get_root.rs @@ -43,7 +43,7 @@ pub fn root_with_opts<'opts, 'buf, T>( where T: 'buf + Follow<'buf> + Verifiable, { - let mut v = Verifier::new(&opts, data); + let mut v = Verifier::new(opts, data); >::run_verifier(&mut v, 0)?; Ok(unsafe { root_unchecked::(data) }) } @@ -73,7 +73,7 @@ pub fn size_prefixed_root_with_opts<'opts, 'buf, T>( where T: 'buf + Follow<'buf> + Verifiable, { - let mut v = Verifier::new(&opts, data); + let mut v = Verifier::new(opts, data); >>::run_verifier(&mut v, 0)?; Ok(unsafe { size_prefixed_root_unchecked::(data) }) } diff --git a/rust/flatbuffers/src/vector.rs b/rust/flatbuffers/src/vector.rs index fe46c5036..0f29e6b60 100644 --- a/rust/flatbuffers/src/vector.rs +++ b/rust/flatbuffers/src/vector.rs @@ -73,7 +73,7 @@ impl<'a, T: 'a> Vector<'a, T> { #[inline(always)] pub fn len(&self) -> usize { - unsafe { read_scalar_at::(&self.0, self.1) as usize } + unsafe { read_scalar_at::(self.0, self.1) as usize } } #[inline(always)] pub fn is_empty(&self) -> bool { @@ -103,7 +103,7 @@ impl<'a, T: SafeSliceAccess + 'a> Vector<'a, T> { let loc = self.1; let sz = size_of::(); debug_assert!(sz > 0); - let len = unsafe { read_scalar_at::(&buf, loc) } as usize; + let len = unsafe { read_scalar_at::(buf, loc) } as usize; let data_buf = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len * sz]; let ptr = data_buf.as_ptr() as *const T; let s: &'a [T] = unsafe { from_raw_parts(ptr, len) }; @@ -144,7 +144,7 @@ pub fn follow_cast_ref<'a, T: Sized + 'a>(buf: &'a [u8], loc: usize) -> &'a T { impl<'a> Follow<'a> for &'a str { type Inner = &'a str; fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let len = unsafe { read_scalar_at::(&buf, loc) } as usize; + let len = unsafe { read_scalar_at::(buf, loc) } as usize; let slice = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len]; unsafe { from_utf8_unchecked(slice) } } @@ -154,7 +154,7 @@ impl<'a> Follow<'a> for &'a str { fn follow_slice_helper(buf: &[u8], loc: usize) -> &[T] { let sz = size_of::(); debug_assert!(sz > 0); - let len = unsafe { read_scalar_at::(&buf, loc) as usize }; + let len = unsafe { read_scalar_at::(buf, loc) as usize }; let data_buf = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len * sz]; let ptr = data_buf.as_ptr() as *const T; let s: &[T] = unsafe { from_raw_parts(ptr, len) };