Makes Clippy happy

pull/171/head
Tpt 4 years ago
parent 1e5847e278
commit b5cb0cce19
  1. 9
      lib/benches/store.rs
  2. 18
      lib/src/model/xsd/date_time.rs
  3. 6
      lib/src/model/xsd/decimal.rs
  4. 6
      lib/src/model/xsd/duration.rs
  5. 12
      lib/src/storage/numeric_encoder.rs
  6. 8
      lib/src/store.rs

@ -2,7 +2,6 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Through
use oxigraph::model::{Dataset, Graph, GraphName, NamedNode, Quad, Triple};
use oxigraph::store::Store;
use rand::random;
use std::iter::FromIterator;
criterion_group!(
store_load,
@ -21,9 +20,7 @@ fn graph_load_bench(c: &mut Criterion) {
group.throughput(Throughput::Elements(*size as u64));
let triples: Vec<_> = create_quads(*size).into_iter().map(Triple::from).collect();
group.bench_function(BenchmarkId::from_parameter(size), |b| {
b.iter(|| {
Graph::from_iter(triples.iter());
});
b.iter(|| triples.iter().collect::<Graph>());
});
}
group.finish();
@ -37,9 +34,7 @@ fn dataset_load_bench(c: &mut Criterion) {
group.throughput(Throughput::Elements(*size as u64));
let quads = create_quads(*size);
group.bench_function(BenchmarkId::from_parameter(size), |b| {
b.iter(|| {
Dataset::from_iter(quads.iter());
});
b.iter(|| quads.iter().collect::<Dataset>());
});
}
group.finish();

@ -105,7 +105,7 @@ impl DateTime {
}
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -284,7 +284,7 @@ impl Time {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -436,7 +436,7 @@ impl Date {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -577,7 +577,7 @@ impl GYearMonth {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -672,7 +672,7 @@ impl GYear {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -776,7 +776,7 @@ impl GMonthDay {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -867,7 +867,7 @@ impl GMonth {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -970,7 +970,7 @@ impl GDay {
self.timestamp.timezone_offset()
}
pub fn to_be_bytes(&self) -> [u8; 18] {
pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes()
}
@ -1327,7 +1327,7 @@ impl Timestamp {
})
}
fn to_be_bytes(&self) -> [u8; 18] {
fn to_be_bytes(self) -> [u8; 18] {
let mut bytes = [0; 18];
bytes[0..16].copy_from_slice(&self.value.to_be_bytes());
bytes[16..18].copy_from_slice(&match &self.timezone_offset {

@ -39,7 +39,7 @@ impl Decimal {
}
#[inline]
pub fn to_be_bytes(&self) -> [u8; 16] {
pub fn to_be_bytes(self) -> [u8; 16] {
self.value.to_be_bytes()
}
@ -159,7 +159,7 @@ impl Decimal {
/// Creates a `f32` from a `Decimal` without taking care of precision
#[inline]
#[allow(clippy::cast_possible_truncation)]
pub fn to_f32(&self) -> f32 {
pub fn to_f32(self) -> f32 {
self.to_f64() as f32
}
@ -175,7 +175,7 @@ impl Decimal {
/// Creates a `f64` from a `Decimal` without taking care of precision
#[inline]
#[allow(clippy::cast_possible_truncation, clippy::cast_precision_loss)]
pub fn to_f64(&self) -> f64 {
pub fn to_f64(self) -> f64 {
(self.value as f64) / (DECIMAL_PART_POW as f64)
}

@ -74,7 +74,7 @@ impl Duration {
self.day_time.all_seconds()
}
pub fn to_be_bytes(&self) -> [u8; 24] {
pub fn to_be_bytes(self) -> [u8; 24] {
let mut bytes = [0; 24];
bytes[0..8].copy_from_slice(&self.year_month.to_be_bytes());
bytes[8..24].copy_from_slice(&self.day_time.to_be_bytes());
@ -273,7 +273,7 @@ impl YearMonthDuration {
self.months
}
pub fn to_be_bytes(&self) -> [u8; 8] {
pub fn to_be_bytes(self) -> [u8; 8] {
self.months.to_be_bytes()
}
@ -425,7 +425,7 @@ impl DayTimeDuration {
self.seconds
}
pub fn to_be_bytes(&self) -> [u8; 16] {
pub fn to_be_bytes(self) -> [u8; 16] {
self.seconds.to_be_bytes()
}

@ -40,7 +40,7 @@ impl StrHash {
}
#[inline]
pub fn to_be_bytes(&self) -> [u8; 16] {
pub fn to_be_bytes(self) -> [u8; 16] {
self.hash.to_be_bytes()
}
}
@ -512,8 +512,8 @@ impl From<LiteralRef<'_>> for EncodedTerm {
let datatype = literal.datatype().as_str();
let native_encoding = match datatype {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString" => {
if let Some(language) = literal.language() {
Some(if let Ok(value) = SmallString::try_from(value) {
literal.language().map(|language| {
if let Ok(value) = SmallString::try_from(value) {
if let Ok(language) = SmallString::try_from(language) {
EncodedTerm::SmallSmallLangStringLiteral { value, language }
} else {
@ -532,10 +532,8 @@ impl From<LiteralRef<'_>> for EncodedTerm {
value_id: StrHash::new(value),
language_id: StrHash::new(language),
}
})
} else {
None
}
}
})
}
"http://www.w3.org/2001/XMLSchema#boolean" => parse_boolean_str(value),
"http://www.w3.org/2001/XMLSchema#string" => {

@ -812,15 +812,15 @@ fn store() -> Result<(), io::Error> {
let result: Result<_, TransactionError<io::Error>> = store.transaction(|t| {
assert!(t.remove(&default_quad)?);
assert_eq!(t.remove(&default_quad)?, false);
assert!(!t.remove(&default_quad)?);
assert!(t.insert(&named_quad)?);
assert_eq!(t.insert(&named_quad)?, false);
assert!(!t.insert(&named_quad)?);
assert!(t.insert(&default_quad)?);
assert_eq!(t.insert(&default_quad)?, false);
assert!(!t.insert(&default_quad)?);
Ok(())
});
result?;
assert_eq!(store.insert(&default_quad)?, false);
assert!(!store.insert(&default_quad)?);
assert_eq!(store.len(), 4);
assert_eq!(store.iter().collect::<Result<Vec<_>, _>>()?, all_quads);

Loading…
Cancel
Save