Skip to content

Commit

Permalink
Use deriving_eq where it makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse99 committed Dec 23, 2012
1 parent e2ca39b commit 2116ad6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
28 changes: 2 additions & 26 deletions src/solution.rs
Expand Up @@ -3,6 +3,7 @@
/// Name of a namespace plus the IRI it expands to.
///
/// This is a sendable type.
#[deriving_eq]
pub struct Namespace {prefix: ~str, path: ~str}

/// Result of matching a triple with a SPARQL query.
Expand All @@ -14,6 +15,7 @@ pub type SolutionRow = ~[@Object];
/// will match the order in the SELECT clause. To allow for faster query execution
/// there may be more bindings than those listed in the SELECT clause. Note that
/// this is a sendable type.
#[deriving_eq]
pub struct Solution
{
pub namespaces: ~[Namespace],
Expand Down Expand Up @@ -112,29 +114,3 @@ pub impl &Solution : ToStr
result
}
}

pub impl Namespace : cmp::Eq
{
pure fn eq(&self, other: &Namespace) -> bool
{
self.prefix == other.prefix && self.path == other.path
}

pure fn ne(&self, other: &Namespace) -> bool
{
!self.eq(other)
}
}

pub impl Solution : cmp::Eq
{
pure fn eq(&self, other: &Solution) -> bool
{
self.namespaces == other.namespaces && self.rows == other.rows
}

pure fn ne(&self, other: &Solution) -> bool
{
!self.eq(other)
}
}
15 changes: 1 addition & 14 deletions src/store.rs
Expand Up @@ -20,22 +20,9 @@ pub type Predicate = ~str;
pub type Triple = {subject: Subject, predicate: Predicate, object: @Object};

/// Predicate and object associated with a subject.
#[deriving_eq]
pub type Entry = {predicate: ~str, object: @Object};

// TODO: This is hopefully temporary: at some point rust should again be able to compare enums without assistence.
pub impl Entry : cmp::Eq
{
pure fn eq(&self, other: &Entry) -> bool
{
self.predicate == other.predicate && self.object == other.object
}

pure fn ne(&self, other: &Entry) -> bool
{
!self.eq(other)
}
}

/// SPARQL extension function.
pub type ExtensionFn = pure fn@ (namespaces: &[Namespace], args: &[@Object]) -> @Object;

Expand Down

0 comments on commit 2116ad6

Please sign in to comment.