Skip to content

Commit

Permalink
feat: better impl of Display for Literal
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonskj committed Oct 16, 2024
1 parent 9beaa58 commit 6af01a7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rdftk_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rdftk_core"
version = "0.5.3"
version = "0.5.4"
authors = ["Simon Johnston <[email protected]>"]
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."
Expand All @@ -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"] }

Expand Down
4 changes: 4 additions & 0 deletions rdftk_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions rdftk_core/src/model/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6af01a7

Please sign in to comment.