From c466096c8d77ea30d977bcfe535adf0033bab3a3 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 16 Feb 2024 10:58:37 -0500 Subject: [PATCH] Fix doc tests; Add from impls for Identifier --- src/abstract_tree/identifier.rs | 12 ++++++++++++ src/context.rs | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/abstract_tree/identifier.rs b/src/abstract_tree/identifier.rs index 900960b..ac091a2 100644 --- a/src/abstract_tree/identifier.rs +++ b/src/abstract_tree/identifier.rs @@ -86,6 +86,18 @@ impl Format for Identifier { } } +impl From for Identifier { + fn from(value: String) -> Self { + Identifier::from_raw_parts(Arc::new(value)) + } +} + +impl From<&str> for Identifier { + fn from(value: &str) -> Self { + Identifier::new(value) + } +} + impl Display for Identifier { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}", self.0) diff --git a/src/context.rs b/src/context.rs index 8741f7b..67d0d9f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -12,7 +12,7 @@ //! let context = Context::new(); //! //! context.set_value( -//! "foobar".to_string(), +//! "foobar".into(), //! Value::String("FOOBAR".to_string()) //! ).unwrap(); //! @@ -84,8 +84,8 @@ impl Context { /// let second_context = Context::new(); /// /// second_context.set_value( - /// "Foo".to_string(), - /// Value::String("Bar".to_string()) + /// "Foo".into(), + /// Value::String("Bar".to_string()) /// ); /// /// first_context.inherit_from(&second_context).unwrap();