work
[pspp] / rust / src / identifier.rs
index 0553b41b119e2e8e5eb74d81f380400aef63dd25..5b0649f533ac99f56c1bbaf9101ef5404fa90142 100644 (file)
@@ -1,3 +1,5 @@
+use std::fmt::{Display, Formatter, Result as FmtResult};
+
 use encoding_rs::{EncoderResult, Encoding};
 use finl_unicode::categories::{CharacterCategories, MajorCategory};
 use thiserror::Error as ThisError;
@@ -28,9 +30,6 @@ impl IdentifierChar for char {
     }
 }
 
-#[derive(Clone, PartialEq, Eq, Debug, Hash)]
-pub struct Identifier(pub UniCase<String>);
-
 #[derive(Clone, Debug, ThisError)]
 pub enum Error {
     #[error("Identifier cannot be empty string.")]
@@ -72,6 +71,9 @@ fn is_reserved_word(s: &str) -> bool {
     false
 }
 
+#[derive(Clone, PartialEq, Eq, Debug, Hash)]
+pub struct Identifier(pub UniCase<String>);
+
 impl Identifier {
     /// Maximum length of an identifier, in bytes.  The limit applies in the
     /// encoding used by the dictionary, not in UTF-8.
@@ -118,3 +120,9 @@ impl Identifier {
         Ok(())
     }
 }
+
+impl Display for Identifier {
+    fn fmt(&self, f: &mut Formatter) -> FmtResult {
+        write!(f, "{}", self.0)
+    }
+}