QuerySolution: implements Eq and Debug

pull/409/head
Tpt 2 years ago committed by Thomas Tanon
parent 31c6bb7815
commit 9063867ec9
  1. 25
      lib/sparesults/src/solution.rs

@ -1,6 +1,7 @@
//! Definition of [`QuerySolution`] structure and associated utility constructions.
use oxrdf::{Term, Variable, VariableRef};
use std::fmt;
use std::iter::Zip;
use std::ops::Index;
use std::rc::Rc;
@ -183,6 +184,30 @@ impl Index<&Variable> for QuerySolution {
}
}
impl PartialEq for QuerySolution {
fn eq(&self, other: &Self) -> bool {
for (k, v) in self.iter() {
if other.get(k) != Some(v) {
return false;
}
}
for (k, v) in other.iter() {
if self.get(k) != Some(v) {
return false;
}
}
true
}
}
impl Eq for QuerySolution {}
impl fmt::Debug for QuerySolution {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_map().entries(self.iter()).finish()
}
}
/// An iterator over [`QuerySolution`] bound variables.
///
/// ```

Loading…
Cancel
Save