From 0ed7319fd70d5233e6cd1d4a67c9326cf4bd2314 Mon Sep 17 00:00:00 2001 From: Tpt Date: Mon, 6 Sep 2021 17:11:07 +0200 Subject: [PATCH] Adds some documentation about S-expressions serialization --- spargebra/src/query.rs | 4 ++++ spargebra/src/update.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spargebra/src/query.rs b/spargebra/src/query.rs index 36d50f73..9a300901 100644 --- a/spargebra/src/query.rs +++ b/spargebra/src/query.rs @@ -8,12 +8,16 @@ use std::str::FromStr; /// A parsed [SPARQL query](https://www.w3.org/TR/sparql11-query/) /// +/// The `Display` trait prints a serialization of the query using SPARQL syntax and +/// `Debug` prints the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). +/// /// ``` /// use spargebra::Query; /// /// let query_str = "SELECT ?s ?p ?o WHERE { ?s ?p ?o . }"; /// let query = Query::parse(query_str, None)?; /// assert_eq!(query.to_string(), query_str); +/// assert_eq!(format!("{:?}", query), "(project (?s ?p ?o) (bgp (triple ?s ?p ?o)))"); /// # Result::Ok::<_, spargebra::ParseError>(()) /// ``` #[derive(Eq, PartialEq, Clone, Hash)] diff --git a/spargebra/src/update.rs b/spargebra/src/update.rs index be4f963d..c434f854 100644 --- a/spargebra/src/update.rs +++ b/spargebra/src/update.rs @@ -8,12 +8,16 @@ use std::str::FromStr; /// A parsed [SPARQL update](https://www.w3.org/TR/sparql11-update/) /// +/// The `Display` trait prints a serialization of the update using SPARQL syntax and +/// `Debug` prints the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). +/// /// ``` /// use spargebra::Update; /// /// let update_str = "CLEAR ALL ;"; /// let update = Update::parse(update_str, None)?; /// assert_eq!(update.to_string().trim(), update_str); +/// assert_eq!(format!("{:?}", update), "(update (clear all))"); /// # Result::Ok::<_, spargebra::ParseError>(()) /// ``` #[derive(Eq, PartialEq, Clone, Hash)]