Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly
2 changes: 1 addition & 1 deletion src/io/rdf/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl<'a, A: ForIRI, AA: ForIndex<A>> OntologyParser<'a, A, AA> {
)),
b,
config,

triple,
simple: d!(),
bnode: d!(),
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
//! implementation of the OWL2 DL specification. It appears to be
//! highly performant, being between 1 and 2 orders of magnitude
//! faster than the OWL API for some tasks.
#![feature(generic_associated_types)]

//extern crate curie;
//extern crate enum_meta;

Expand Down
8 changes: 8 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,14 @@ pub trait Ontology<A> {
fn mut_doc_iri(&mut self) -> &mut Option<IRI<A>>;
}

pub trait IterableOntology<A>: IntoIterator {
type Iterator<'collection>: Iterator<Item = &'collection AnnotatedAxiom<A>>
where
Self: 'collection, A:'collection;

fn iter<'c>(&'c self) -> Self::Iterator<'c>;
}

/// Add or remove axioms to an `MutableOntology`
pub trait MutableOntology<A> {
/// Insert an axiom into the ontology.
Expand Down
9 changes: 9 additions & 0 deletions src/ontology/axiom_mapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ impl<A: ForIRI, AA: ForIndex<A>> Ontology<A> for AxiomMappedOntology<A, AA> {
}
}

impl<A: ForIRI, AA: ForIndex<A>> IterableOntology<A> for AxiomMappedOntology<A, AA> {
type Iterator<'c> = AxiomMappedIter<'c, A, AA>
where A:'c, AA:'c;

fn iter<'c>(&'c self) -> AxiomMappedIter<'c, A, AA>{
self.0.i().iter()
}
}

impl<A: ForIRI, AA: ForIndex<A>> MutableOntology<A> for AxiomMappedOntology<A, AA> {
fn insert<IAA>(&mut self, ax: IAA) -> bool
where
Expand Down
2 changes: 2 additions & 0 deletions src/ontology/indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl<A: ForIRI, T: ?Sized> ForIndex<A> for T where
/// do, or the it will be dropped entirely. The `SetIndex` is a simple
/// way to achieving this.
pub trait OntologyIndex<A: ForIRI, AA: ForIndex<A>> {

/// Potentially insert an AnnotatedAxiom to the index.
///
/// If the index did not have this value present, true is returned.
Expand Down Expand Up @@ -179,6 +180,7 @@ impl<A: ForIRI, AA: ForIndex<A>, I: OntologyIndex<A, AA>> Ontology<A>
fn mut_doc_iri(&mut self) -> &mut Option<IRI<A>> {
&mut self.2
}

}

impl<A: ForIRI, AA: ForIndex<A>, I: OntologyIndex<A, AA>> MutableOntology<A>
Expand Down
15 changes: 10 additions & 5 deletions src/ontology/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ impl<A: ForIRI> SetOntology<A> {
pub fn from_index<AA: ForIndex<A>>(oid: OntologyID<A>, si: SetIndex<A, AA>) -> SetOntology<A> {
(oid, si.into_iter().map(|s| s.unwrap())).into()
}

/// Gets an iterator that visits the annotated axioms of the ontology.
pub fn iter(&self) -> SetIter<'_, A> {
SetIter(self.0.i().0.iter())
}
}

impl<A: ForIRI> Ontology<A> for SetOntology<A> {
Expand All @@ -75,6 +70,16 @@ impl<A: ForIRI> Ontology<A> for SetOntology<A> {
}
}

impl<A: ForIRI> IterableOntology<A> for SetOntology<A> {
type Iterator<'c> = SetIter<'c, A>
where A:'c;

/// Gets an iterator that visits the annotated axioms of the ontology.
fn iter<'c>(&'c self) -> SetIter<'c, A> {
SetIter(self.0.i().0.iter())
}
}

/// An Interator for `SetOntology`
pub struct SetIter<'a, A: ForIRI>(std::collections::hash_set::Iter<'a, AnnotatedAxiom<A>>);

Expand Down