Makes the new Clippy happy

pull/216/head
Tpt 2 years ago
parent 61129511d8
commit b04bdcceed
  1. 30
      lib/src/io/format.rs
  2. 4
      lib/src/lib.rs
  3. 174
      lib/src/sparql/plan.rs
  4. 18
      lib/src/storage/binary_encoder.rs

@ -23,9 +23,9 @@ impl GraphFormat {
#[inline] #[inline]
pub fn iri(self) -> &'static str { pub fn iri(self) -> &'static str {
match self { match self {
GraphFormat::NTriples => "http://www.w3.org/ns/formats/N-Triples", Self::NTriples => "http://www.w3.org/ns/formats/N-Triples",
GraphFormat::Turtle => "http://www.w3.org/ns/formats/Turtle", Self::Turtle => "http://www.w3.org/ns/formats/Turtle",
GraphFormat::RdfXml => "http://www.w3.org/ns/formats/RDF_XML", Self::RdfXml => "http://www.w3.org/ns/formats/RDF_XML",
} }
} }
@ -39,9 +39,9 @@ impl GraphFormat {
#[inline] #[inline]
pub fn media_type(self) -> &'static str { pub fn media_type(self) -> &'static str {
match self { match self {
GraphFormat::NTriples => "application/n-triples", Self::NTriples => "application/n-triples",
GraphFormat::Turtle => "text/turtle", Self::Turtle => "text/turtle",
GraphFormat::RdfXml => "application/rdf+xml", Self::RdfXml => "application/rdf+xml",
} }
} }
@ -55,9 +55,9 @@ impl GraphFormat {
#[inline] #[inline]
pub fn file_extension(self) -> &'static str { pub fn file_extension(self) -> &'static str {
match self { match self {
GraphFormat::NTriples => "nt", Self::NTriples => "nt",
GraphFormat::Turtle => "ttl", Self::Turtle => "ttl",
GraphFormat::RdfXml => "rdf", Self::RdfXml => "rdf",
} }
} }
/// Looks for a known format from a media type. /// Looks for a known format from a media type.
@ -125,8 +125,8 @@ impl DatasetFormat {
#[inline] #[inline]
pub fn iri(self) -> &'static str { pub fn iri(self) -> &'static str {
match self { match self {
DatasetFormat::NQuads => "http://www.w3.org/ns/formats/N-Quads", Self::NQuads => "http://www.w3.org/ns/formats/N-Quads",
DatasetFormat::TriG => "http://www.w3.org/ns/formats/TriG", Self::TriG => "http://www.w3.org/ns/formats/TriG",
} }
} }
@ -140,8 +140,8 @@ impl DatasetFormat {
#[inline] #[inline]
pub fn media_type(self) -> &'static str { pub fn media_type(self) -> &'static str {
match self { match self {
DatasetFormat::NQuads => "application/n-quads", Self::NQuads => "application/n-quads",
DatasetFormat::TriG => "application/trig", Self::TriG => "application/trig",
} }
} }
@ -155,8 +155,8 @@ impl DatasetFormat {
#[inline] #[inline]
pub fn file_extension(self) -> &'static str { pub fn file_extension(self) -> &'static str {
match self { match self {
DatasetFormat::NQuads => "nq", Self::NQuads => "nq",
DatasetFormat::TriG => "trig", Self::TriG => "trig",
} }
} }
/// Looks for a known format from a media type. /// Looks for a known format from a media type.

@ -75,7 +75,7 @@
clippy::needless_continue, clippy::needless_continue,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
clippy::non_ascii_literal, clippy::non_ascii_literal,
//TODO clippy::nonstandard_macro_braces, clippy::nonstandard_macro_braces,
//TODO clippy::option_if_let_else, //TODO clippy::option_if_let_else,
// clippy::panic, clippy::panic_in_result_fn, does not work well with tests // clippy::panic, clippy::panic_in_result_fn, does not work well with tests
clippy::path_buf_push_overwrite, clippy::path_buf_push_overwrite,
@ -83,7 +83,7 @@
clippy::print_stdout, clippy::print_stdout,
clippy::range_minus_one, clippy::range_minus_one,
clippy::range_plus_one, clippy::range_plus_one,
//TODO clippy::rc_mutex, clippy::rc_mutex,
clippy::enum_variant_names, clippy::enum_variant_names,
//TODO clippy::redundant_closure_for_method_calls, //TODO clippy::redundant_closure_for_method_calls,
clippy::redundant_else, clippy::redundant_else,

@ -461,112 +461,110 @@ pub enum PlanExpression {
impl PlanExpression { impl PlanExpression {
pub fn lookup_used_variables(&self, callback: &mut impl FnMut(usize)) { pub fn lookup_used_variables(&self, callback: &mut impl FnMut(usize)) {
match self { match self {
PlanExpression::Variable(v) | PlanExpression::Bound(v) => { Self::Variable(v) | Self::Bound(v) => {
callback(*v); callback(*v);
} }
PlanExpression::Constant(_) Self::Constant(_)
| PlanExpression::Rand | Self::Rand
| PlanExpression::Now | Self::Now
| PlanExpression::Uuid | Self::Uuid
| PlanExpression::StrUuid | Self::StrUuid
| PlanExpression::BNode(None) => (), | Self::BNode(None) => (),
PlanExpression::UnaryPlus(e) Self::UnaryPlus(e)
| PlanExpression::UnaryMinus(e) | Self::UnaryMinus(e)
| PlanExpression::Not(e) | Self::Not(e)
| PlanExpression::BNode(Some(e)) | Self::BNode(Some(e))
| PlanExpression::Str(e) | Self::Str(e)
| PlanExpression::Lang(e) | Self::Lang(e)
| PlanExpression::Datatype(e) | Self::Datatype(e)
| PlanExpression::Iri(e) | Self::Iri(e)
| PlanExpression::Abs(e) | Self::Abs(e)
| PlanExpression::Ceil(e) | Self::Ceil(e)
| PlanExpression::Floor(e) | Self::Floor(e)
| PlanExpression::Round(e) | Self::Round(e)
| PlanExpression::UCase(e) | Self::UCase(e)
| PlanExpression::LCase(e) | Self::LCase(e)
| PlanExpression::StrLen(e) | Self::StrLen(e)
| PlanExpression::EncodeForUri(e) | Self::EncodeForUri(e)
| PlanExpression::Year(e) | Self::Year(e)
| PlanExpression::Month(e) | Self::Month(e)
| PlanExpression::Day(e) | Self::Day(e)
| PlanExpression::Hours(e) | Self::Hours(e)
| PlanExpression::Minutes(e) | Self::Minutes(e)
| PlanExpression::Seconds(e) | Self::Seconds(e)
| PlanExpression::Timezone(e) | Self::Timezone(e)
| PlanExpression::Tz(e) | Self::Tz(e)
| PlanExpression::Md5(e) | Self::Md5(e)
| PlanExpression::Sha1(e) | Self::Sha1(e)
| PlanExpression::Sha256(e) | Self::Sha256(e)
| PlanExpression::Sha384(e) | Self::Sha384(e)
| PlanExpression::Sha512(e) | Self::Sha512(e)
| PlanExpression::IsIri(e) | Self::IsIri(e)
| PlanExpression::IsBlank(e) | Self::IsBlank(e)
| PlanExpression::IsLiteral(e) | Self::IsLiteral(e)
| PlanExpression::IsNumeric(e) | Self::IsNumeric(e)
| PlanExpression::IsTriple(e) | Self::IsTriple(e)
| PlanExpression::Subject(e) | Self::Subject(e)
| PlanExpression::Predicate(e) | Self::Predicate(e)
| PlanExpression::Object(e) | Self::Object(e)
| PlanExpression::BooleanCast(e) | Self::BooleanCast(e)
| PlanExpression::DoubleCast(e) | Self::DoubleCast(e)
| PlanExpression::FloatCast(e) | Self::FloatCast(e)
| PlanExpression::DecimalCast(e) | Self::DecimalCast(e)
| PlanExpression::IntegerCast(e) | Self::IntegerCast(e)
| PlanExpression::DateCast(e) | Self::DateCast(e)
| PlanExpression::TimeCast(e) | Self::TimeCast(e)
| PlanExpression::DateTimeCast(e) | Self::DateTimeCast(e)
| PlanExpression::DurationCast(e) | Self::DurationCast(e)
| PlanExpression::YearMonthDurationCast(e) | Self::YearMonthDurationCast(e)
| PlanExpression::DayTimeDurationCast(e) | Self::DayTimeDurationCast(e)
| PlanExpression::StringCast(e) => e.lookup_used_variables(callback), | Self::StringCast(e) => e.lookup_used_variables(callback),
PlanExpression::Or(a, b) Self::Or(a, b)
| PlanExpression::And(a, b) | Self::And(a, b)
| PlanExpression::Equal(a, b) | Self::Equal(a, b)
| PlanExpression::Greater(a, b) | Self::Greater(a, b)
| PlanExpression::GreaterOrEqual(a, b) | Self::GreaterOrEqual(a, b)
| PlanExpression::Less(a, b) | Self::Less(a, b)
| PlanExpression::LessOrEqual(a, b) | Self::LessOrEqual(a, b)
| PlanExpression::Add(a, b) | Self::Add(a, b)
| PlanExpression::Subtract(a, b) | Self::Subtract(a, b)
| PlanExpression::Multiply(a, b) | Self::Multiply(a, b)
| PlanExpression::Divide(a, b) | Self::Divide(a, b)
| PlanExpression::LangMatches(a, b) | Self::LangMatches(a, b)
| PlanExpression::Contains(a, b) | Self::Contains(a, b)
| PlanExpression::StrStarts(a, b) | Self::StrStarts(a, b)
| PlanExpression::StrEnds(a, b) | Self::StrEnds(a, b)
| PlanExpression::StrBefore(a, b) | Self::StrBefore(a, b)
| PlanExpression::StrAfter(a, b) | Self::StrAfter(a, b)
| PlanExpression::StrLang(a, b) | Self::StrLang(a, b)
| PlanExpression::StrDt(a, b) | Self::StrDt(a, b)
| PlanExpression::SameTerm(a, b) | Self::SameTerm(a, b)
| PlanExpression::SubStr(a, b, None) | Self::SubStr(a, b, None)
| PlanExpression::Regex(a, b, None) => { | Self::Regex(a, b, None) => {
a.lookup_used_variables(callback); a.lookup_used_variables(callback);
b.lookup_used_variables(callback); b.lookup_used_variables(callback);
} }
PlanExpression::If(a, b, c) Self::If(a, b, c)
| PlanExpression::SubStr(a, b, Some(c)) | Self::SubStr(a, b, Some(c))
| PlanExpression::Regex(a, b, Some(c)) | Self::Regex(a, b, Some(c))
| PlanExpression::Replace(a, b, c, None) | Self::Replace(a, b, c, None)
| PlanExpression::Triple(a, b, c) => { | Self::Triple(a, b, c) => {
a.lookup_used_variables(callback); a.lookup_used_variables(callback);
b.lookup_used_variables(callback); b.lookup_used_variables(callback);
c.lookup_used_variables(callback); c.lookup_used_variables(callback);
} }
PlanExpression::Replace(a, b, c, Some(d)) => { Self::Replace(a, b, c, Some(d)) => {
a.lookup_used_variables(callback); a.lookup_used_variables(callback);
b.lookup_used_variables(callback); b.lookup_used_variables(callback);
c.lookup_used_variables(callback); c.lookup_used_variables(callback);
d.lookup_used_variables(callback); d.lookup_used_variables(callback);
} }
PlanExpression::Concat(es) Self::Concat(es) | Self::Coalesce(es) | Self::CustomFunction(_, es) => {
| PlanExpression::Coalesce(es)
| PlanExpression::CustomFunction(_, es) => {
for e in es { for e in es {
e.lookup_used_variables(callback); e.lookup_used_variables(callback);
} }
} }
PlanExpression::Exists(e) => { Self::Exists(e) => {
e.lookup_used_variables(callback); e.lookup_used_variables(callback);
} }
} }

@ -67,15 +67,15 @@ impl QuadEncoding {
pub fn decode(self, buffer: &[u8]) -> Result<EncodedQuad, StorageError> { pub fn decode(self, buffer: &[u8]) -> Result<EncodedQuad, StorageError> {
let mut cursor = Cursor::new(&buffer); let mut cursor = Cursor::new(&buffer);
match self { match self {
QuadEncoding::Spog => cursor.read_spog_quad(), Self::Spog => cursor.read_spog_quad(),
QuadEncoding::Posg => cursor.read_posg_quad(), Self::Posg => cursor.read_posg_quad(),
QuadEncoding::Ospg => cursor.read_ospg_quad(), Self::Ospg => cursor.read_ospg_quad(),
QuadEncoding::Gspo => cursor.read_gspo_quad(), Self::Gspo => cursor.read_gspo_quad(),
QuadEncoding::Gpos => cursor.read_gpos_quad(), Self::Gpos => cursor.read_gpos_quad(),
QuadEncoding::Gosp => cursor.read_gosp_quad(), Self::Gosp => cursor.read_gosp_quad(),
QuadEncoding::Dspo => cursor.read_dspo_quad(), Self::Dspo => cursor.read_dspo_quad(),
QuadEncoding::Dpos => cursor.read_dpos_quad(), Self::Dpos => cursor.read_dpos_quad(),
QuadEncoding::Dosp => cursor.read_dosp_quad(), Self::Dosp => cursor.read_dosp_quad(),
} }
} }
} }

Loading…
Cancel
Save