forked from BigfootDev/flatbuffers
Rust: Fixed cargo clippy on non-generated code (#5485)
* Cargo clippy lints * more lints * more lints * Restored a doc comment * Comment on float eps-eq and adjusted casting
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
4b870aca98
commit
c0282873fb
@@ -25,7 +25,7 @@ use endian_scalar::{read_scalar, read_scalar_at};
|
||||
use follow::Follow;
|
||||
use primitives::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Vector<'a, T: 'a>(&'a [u8], usize, PhantomData<T>);
|
||||
|
||||
impl<'a, T: 'a> Vector<'a, T> {
|
||||
@@ -42,6 +42,10 @@ impl<'a, T: 'a> Vector<'a, T> {
|
||||
pub fn len(&self) -> usize {
|
||||
read_scalar::<UOffsetT>(&self.0[self.1 as usize..]) as usize
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Follow<'a> + 'a> Vector<'a, T> {
|
||||
@@ -102,8 +106,7 @@ impl<'a> Follow<'a> for &'a str {
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let len = read_scalar_at::<UOffsetT>(&buf, loc) as usize;
|
||||
let slice = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len];
|
||||
let s = unsafe { from_utf8_unchecked(slice) };
|
||||
s
|
||||
unsafe { from_utf8_unchecked(slice) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user