Oxrdf: Makes Display for Graph and Dataset return proper NTriples and NQuads

pull/417/head
Tpt 2 years ago committed by Thomas Tanon
parent 1570a3a4f1
commit 1ffb559ee2
  1. 7
      lib/oxrdf/src/dataset.rs
  2. 3
      lib/oxrdf/src/graph.rs

@ -18,6 +18,9 @@
//! // direct access to a dataset graph
//! let results: Vec<_> = dataset.graph(ex).iter().collect();
//! assert_eq!(vec![TripleRef::new(ex, ex, ex)], results);
//!
//! // Print
//! assert_eq!(dataset.to_string(), "<http://example.com> <http://example.com> <http://example.com> <http://example.com> .\n");
//! # Result::<_,Box<dyn std::error::Error>>::Ok(())
//! ```
//!
@ -901,7 +904,7 @@ impl<'a, T: Into<QuadRef<'a>>> Extend<T> for Dataset {
impl fmt::Display for Dataset {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for t in self {
writeln!(f, "{t}")?;
writeln!(f, "{t} .")?;
}
Ok(())
}
@ -1236,7 +1239,7 @@ impl<'a, 'b> IntoIterator for &'b GraphView<'a> {
impl<'a> fmt::Display for GraphView<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for t in self {
writeln!(f, "{t}")?;
writeln!(f, "{t} .")?;
}
Ok(())
}

@ -14,6 +14,9 @@
//! // simple filter
//! let results: Vec<_> = graph.triples_for_subject(ex).collect();
//! assert_eq!(vec![triple], results);
//!
//! // Print
//! assert_eq!(graph.to_string(), "<http://example.com> <http://example.com> <http://example.com> .\n");
//! # Result::<_,Box<dyn std::error::Error>>::Ok(())
//! ```
//!

Loading…
Cancel
Save