From 6af01a7b745cec1578e0ab61894b29c25153eefe Mon Sep 17 00:00:00 2001 From: Simon Johnston Date: Tue, 15 Oct 2024 20:28:52 -0700 Subject: [PATCH] feat: better impl of `Display` for `Literal` --- rdftk_core/Cargo.toml | 4 ++-- rdftk_core/README.md | 4 ++++ rdftk_core/src/model/literal.rs | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/rdftk_core/Cargo.toml b/rdftk_core/Cargo.toml index fbfe03e..79e832a 100644 --- a/rdftk_core/Cargo.toml +++ b/rdftk_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rdftk_core" -version = "0.5.3" +version = "0.5.4" authors = ["Simon Johnston "] edition = "2021" description = "This crate provides the core RDF data model; concrete implementations for Statements and Literals, along with a Resource type that provides a builder-like experience for models." @@ -26,7 +26,7 @@ bimap = "0.6" language-tags = "0.3.2" lazy_static = "1.5" rdftk_iri = { version = "0.2.5", path = "../rdftk_iri" } -rdftk_names = { version = "0.2.4", path = "../rdftk_names" } +rdftk_names = { version = "0.2.5", path = "../rdftk_names" } unique_id = "0.1" uuid = { version = "1.10", features = ["v4"] } diff --git a/rdftk_core/README.md b/rdftk_core/README.md index 258fdfa..e6e7a5b 100644 --- a/rdftk_core/README.md +++ b/rdftk_core/README.md @@ -54,6 +54,10 @@ pub fn make_statements() -> StatementList { ### Version 0.5.3 +* Feature: better implementation of `Display` for `Literal`. + +### Version 0.5.3 + * Feature: add SKOS to PrefixMapping commons. ### Version 0.5.2 diff --git a/rdftk_core/src/model/literal.rs b/rdftk_core/src/model/literal.rs index af43f1c..73a0a59 100644 --- a/rdftk_core/src/model/literal.rs +++ b/rdftk_core/src/model/literal.rs @@ -825,9 +825,19 @@ impl Eq for Literal {} impl Display for Literal { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self.data_type() { - // Some(DataType::String) => write!(f, "\"{}\"", self.lexical_form()), Some(DataType::Iri) => write!(f, "<{}>", self.lexical_form()), - // Some(DataType::Boolean) => write!(f, "{}", self.lexical_form()), + Some(DataType::Boolean) + | Some(DataType::Long) + | Some(DataType::Int) + | Some(DataType::Short) + | Some(DataType::Byte) + | Some(DataType::UnsignedLong) + | Some(DataType::UnsignedInt) + | Some(DataType::UnsignedShort) + | Some(DataType::UnsignedByte) + | Some(DataType::Float) + | Some(DataType::Double) + | Some(DataType::Decimal) => write!(f, "{}", self.lexical_form()), _ => { write!( f,