Skip to content

Commit

Permalink
revert explicit imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mkatychev committed Jul 26, 2024
1 parent e30b824 commit 47805e1
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 29 deletions.
6 changes: 4 additions & 2 deletions api/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! for different kinds of datasets,
//! as well as a few implementations for them.

use std::error::Error;

use crate::graph::adapter::{DatasetGraph, PartialUnionGraph, UnionGraph};
use crate::quad::{iter_spog, Quad};
use crate::source::{IntoSource, QuadSource, StreamResult};
Expand Down Expand Up @@ -56,7 +58,7 @@ pub trait Dataset {
where
Self: 'x;
/// The error type that this dataset may raise.
type Error: std::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;

/// An iterator visiting all quads of this dataset in arbitrary order.
///
Expand Down Expand Up @@ -346,7 +348,7 @@ pub type MdResult<D, T> = std::result::Result<T, <D as MutableDataset>::Mutation
/// see also [`SetDataset`].
pub trait MutableDataset: Dataset {
/// The error type that this dataset may raise during mutations.
type MutationError: std::error::Error + Send + Sync + 'static;
type MutationError: Error + Send + Sync + 'static;

/// Insert the given quad in this dataset.
///
Expand Down
6 changes: 4 additions & 2 deletions api/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! for different kinds of graph,
//! as well as a few implementations for them.

use std::error::Error;

use crate::dataset::adapter::GraphAsDataset;
use crate::source::{IntoSource, StreamResult, TripleSource};
use crate::term::{matcher::TermMatcher, SimpleTerm, Term};
Expand Down Expand Up @@ -53,7 +55,7 @@ pub trait Graph {
where
Self: 'x;
/// The error type that this graph may raise.
type Error: std::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;

/// An iterator visiting all triples of this graph in arbitrary order.
///
Expand Down Expand Up @@ -305,7 +307,7 @@ pub type MgResult<G, T> = std::result::Result<T, <G as MutableGraph>::MutationEr
/// see also [`SetGraph`].
pub trait MutableGraph: Graph {
/// The error type that this graph may raise during mutations.
type MutationError: std::error::Error + Send + Sync + 'static;
type MutationError: Error + Send + Sync + 'static;

/// Insert in this graph a triple made of the the given terms.
///
Expand Down
12 changes: 6 additions & 6 deletions api/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub use _stream_error::*;
mod _triple;
pub use _triple::*;

use std::convert::Infallible;
use std::{convert::Infallible, error::Error};

/// A source produces [items](Source::Item), and may also fail in the process.
///
Expand All @@ -85,7 +85,7 @@ pub trait Source {
/// The type of items this source yields.
type Item<'x>;
/// The type of errors produced by this source.
type Error: std::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;

/// Call f for some item(s) (possibly zero) from this source, if any.
///
Expand All @@ -94,7 +94,7 @@ pub trait Source {
/// Return an error if either the source or `f` errs.
fn try_for_some_item<E, F>(&mut self, f: F) -> StreamResult<bool, Self::Error, E>
where
E: std::error::Error + Send + Sync + 'static,
E: Error + Send + Sync + 'static,
F: FnMut(Self::Item<'_>) -> Result<(), E>;

/// Call f for all items from this source.
Expand All @@ -104,7 +104,7 @@ pub trait Source {
fn try_for_each_item<F, E>(&mut self, mut f: F) -> StreamResult<(), Self::Error, E>
where
F: FnMut(Self::Item<'_>) -> Result<(), E>,
E: std::error::Error + Send + Sync + 'static,
E: Error + Send + Sync + 'static,
{
while self.try_for_some_item(&mut f)? {}
Ok(())
Expand Down Expand Up @@ -198,14 +198,14 @@ pub trait Source {
impl<'a, I, T, E> Source for I
where
I: Iterator<Item = Result<T, E>> + 'a,
E: std::error::Error + Send + Sync + 'static,
E: Error + Send + Sync + 'static,
{
type Item<'x> = T;
type Error = E;

fn try_for_some_item<E2, F>(&mut self, mut f: F) -> StreamResult<bool, Self::Error, E2>
where
E2: std::error::Error + Send + Sync + 'static,
E2: Error + Send + Sync + 'static,
F: FnMut(Self::Item<'_>) -> Result<(), E2>,
{
match self.next() {
Expand Down
5 changes: 3 additions & 2 deletions api/src/sparql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::source::TripleSource;
use crate::term::Term;

use std::borrow::Borrow;
use std::error::Error;

/// A dataset that can be queried with SPARQL.
pub trait SparqlDataset {
Expand All @@ -41,7 +42,7 @@ pub trait SparqlDataset {
/// The type of triples that GRAPH and DESCRIBE queries will return.
type TriplesResult: TripleSource;
/// The type of errors that processing SPARQL queries may raise.
type SparqlError: std::error::Error + Send + Sync + 'static;
type SparqlError: Error + Send + Sync + 'static;
/// The type representing pre-processed queries.
///
/// See [`prepare_query`](#tymethod.prepare_query) for more detail.
Expand Down Expand Up @@ -81,7 +82,7 @@ pub trait SparqlDataset {
/// [`prepare_query`](SparqlDataset::prepare_query) method.
pub trait Query: Sized {
/// The error type that might be raised when parsing a query.
type Error: std::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;
/// Parse the given text into a [`Query`].
fn parse(query_source: &str) -> Result<Self, Self::Error>;
}
Expand Down
3 changes: 2 additions & 1 deletion inmem/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use sophia_api::term::{FromTerm, GraphName, SimpleTerm, Term};

use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::error::Error;

/// Abstraction of the short numeric indices representing [terms](Term) in a [`TermIndex`].
pub trait Index: Copy + std::fmt::Debug + Ord {
Expand Down Expand Up @@ -64,7 +65,7 @@ pub trait TermIndex {
/// The type of [indices](Index) used by this [`TermIndex`]
type Index: Index;
/// The type of error that this [`TermIndex`] may raise
type Error: std::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;

/// Get the index corresponding to term `t`, if it exists.
///
Expand Down
26 changes: 14 additions & 12 deletions isomorphism/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::error::Error;

use super::*;
use sophia_api::ns::xsd;
use sophia_api::term::{assert_consistent_term_impl, BnodeId, IriRef, Term, TermKind};
Expand All @@ -11,7 +13,7 @@ const LIT_ALICE: MyTerm = MyTerm::String("alice");
const LIT_BOB: MyTerm = MyTerm::String("bob");

#[test]
fn no_bnode() -> Result<(), Box<dyn std::error::Error>> {
fn no_bnode() -> Result<(), Box<dyn Error>> {
let make_dataset = |i1: &'static str, i2: &'static str| -> Vec<([MyTerm; 3], Option<MyTerm>)> {
let i1 = MyTerm::Iri(i1);
let i2 = MyTerm::Iri(i2);
Expand Down Expand Up @@ -46,7 +48,7 @@ fn no_bnode() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn simple() -> Result<(), Box<dyn std::error::Error>> {
fn simple() -> Result<(), Box<dyn Error>> {
let make_dataset = |b1: &'static str, b2: &'static str| -> Vec<([MyTerm; 3], Option<MyTerm>)> {
let b1 = MyTerm::Bnode(b1);
let b2 = MyTerm::Bnode(b2);
Expand Down Expand Up @@ -82,7 +84,7 @@ fn simple() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn no_bnode_quoted_triple() -> Result<(), Box<dyn std::error::Error>> {
fn no_bnode_quoted_triple() -> Result<(), Box<dyn Error>> {
const A: MyTerm = MyTerm::Iri("#a");
const B: MyTerm = MyTerm::Iri("#b");
const C: MyTerm = MyTerm::Iri("#c");
Expand Down Expand Up @@ -114,7 +116,7 @@ fn no_bnode_quoted_triple() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn quoted_triple() -> Result<(), Box<dyn std::error::Error>> {
fn quoted_triple() -> Result<(), Box<dyn Error>> {
const A: MyTerm = MyTerm::Bnode("a");
const B: MyTerm = MyTerm::Bnode("b");
const C: MyTerm = MyTerm::Bnode("c");
Expand Down Expand Up @@ -158,7 +160,7 @@ fn make_chain(ids: &'static str) -> Vec<[MyTerm; 4]> {
}

#[test]
fn chain() -> Result<(), Box<dyn std::error::Error>> {
fn chain() -> Result<(), Box<dyn Error>> {
let d1 = make_chain("abcdefghij");
assert!(isomorphic_datasets(&d1, &d1)?);
let d2 = make_chain("EDCBAJIHGF");
Expand All @@ -171,7 +173,7 @@ fn chain() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn cycle2() -> Result<(), Box<dyn std::error::Error>> {
fn cycle2() -> Result<(), Box<dyn Error>> {
let d1 = make_chain("aba");
assert!(isomorphic_datasets(&d1, &d1)?);
let d2 = make_chain("BAB");
Expand All @@ -181,7 +183,7 @@ fn cycle2() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn cycle_long() -> Result<(), Box<dyn std::error::Error>> {
fn cycle_long() -> Result<(), Box<dyn Error>> {
let d1 = make_chain("abcdefghia");
assert!(isomorphic_datasets(&d1, &d1)?);
let d2 = make_chain("EBCDAIGHFE");
Expand All @@ -195,7 +197,7 @@ fn cycle_long() -> Result<(), Box<dyn std::error::Error>> {

#[test]
#[ignore]
fn cycle_pathological() -> Result<(), Box<dyn std::error::Error>> {
fn cycle_pathological() -> Result<(), Box<dyn Error>> {
// This case is tricky (and does not work with the current implementation).
// Both graphs contain the same number of (blank nodes) and the same number of arcs.
// All blank nodes are locally undistinguishable from each other:
Expand All @@ -211,7 +213,7 @@ fn cycle_pathological() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn cycle_almost_pathological() -> Result<(), Box<dyn std::error::Error>> {
fn cycle_almost_pathological() -> Result<(), Box<dyn Error>> {
// This is uses the same graphs as above (cycle_pathological),
// but *one* of the blank nodes is distinguished by an additional property,
// which breaks symmetry and allow the algorithm to give the correct answer.
Expand Down Expand Up @@ -247,7 +249,7 @@ fn make_clique(ids: &'static str) -> Vec<[MyTerm; 4]> {
}

#[test]
fn clique() -> Result<(), Box<dyn std::error::Error>> {
fn clique() -> Result<(), Box<dyn Error>> {
let d1 = make_clique("abcde");
assert!(isomorphic_datasets(&d1, &d1)?);

Expand Down Expand Up @@ -278,7 +280,7 @@ fn make_tree(ids: &'static str) -> Vec<[MyTerm; 4]> {
}

#[test]
fn tree() -> Result<(), Box<dyn std::error::Error>> {
fn tree() -> Result<(), Box<dyn Error>> {
let d1 = make_tree("abcdefghij");
assert!(isomorphic_datasets(&d1, &d1)?);

Expand All @@ -292,7 +294,7 @@ fn tree() -> Result<(), Box<dyn std::error::Error>> {
}

#[test]
fn predicate_and_gname() -> Result<(), Box<dyn std::error::Error>> {
fn predicate_and_gname() -> Result<(), Box<dyn Error>> {
let rel = MyTerm::Iri("tag:rel");
let b1 = MyTerm::Bnode("b1");
let b2 = MyTerm::Bnode("b2");
Expand Down
6 changes: 4 additions & 2 deletions turtle/src/serializer/trig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ impl Stringifier for TrigSerializer<Vec<u8>> {

#[cfg(test)]
pub(crate) mod test {
use std::error::Error;

use super::*;
use sophia_api::term::SimpleTerm;

Expand Down Expand Up @@ -177,7 +179,7 @@ pub(crate) mod test {
];

#[test]
fn roundtrip_not_pretty() -> Result<(), Box<dyn std::error::Error>> {
fn roundtrip_not_pretty() -> Result<(), Box<dyn Error>> {
for ttl in TESTS {
println!("==========\n{}\n----------", ttl);
let g1: Vec<Spog<SimpleTerm>> = crate::parser::trig::parse_str(ttl).collect_quads()?;
Expand All @@ -195,7 +197,7 @@ pub(crate) mod test {
}

#[test]
fn roundtrip_pretty() -> Result<(), Box<dyn std::error::Error>> {
fn roundtrip_pretty() -> Result<(), Box<dyn Error>> {
for ttl in TESTS {
println!("==========\n{}\n----------", ttl);
let g1: Vec<Spog<SimpleTerm>> = crate::parser::trig::parse_str(ttl).collect_quads()?;
Expand Down
6 changes: 4 additions & 2 deletions turtle/src/serializer/turtle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ impl Stringifier for TurtleSerializer<Vec<u8>> {

#[cfg(test)]
pub(crate) mod test {
use std::error::Error;

use super::*;
use sophia_api::graph::Graph;
use sophia_isomorphism::isomorphic_graphs;
Expand Down Expand Up @@ -245,7 +247,7 @@ pub(crate) mod test {
];

#[test]
fn roundtrip_not_pretty() -> Result<(), Box<dyn std::error::Error>> {
fn roundtrip_not_pretty() -> Result<(), Box<dyn Error>> {
for ttl in TESTS {
println!("==========\n{}\n----------", ttl);
let g1: Vec<[SimpleTerm; 3]> =
Expand All @@ -265,7 +267,7 @@ pub(crate) mod test {
}

#[test]
fn roundtrip_pretty() -> Result<(), Box<dyn std::error::Error>> {
fn roundtrip_pretty() -> Result<(), Box<dyn Error>> {
for ttl in TESTS {
println!("==========\n{}\n----------", ttl);
let g1: Vec<[SimpleTerm; 3]> =
Expand Down

0 comments on commit 47805e1

Please sign in to comment.