From 6cbe21b84ffd274f92791ab8dbf9af6527978688 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 21 Mar 2019 20:30:25 +0100 Subject: oops --- dhall_core/src/label.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 dhall_core/src/label.rs (limited to 'dhall_core/src/label.rs') diff --git a/dhall_core/src/label.rs b/dhall_core/src/label.rs new file mode 100644 index 0000000..3633b93 --- /dev/null +++ b/dhall_core/src/label.rs @@ -0,0 +1,38 @@ +use std::fmt::{self, Display}; +use std::rc::Rc; + +// The type for labels throughout the AST +// It owns the data because otherwise lifetimes would make recursive imports impossible +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Label(Rc); + +impl From for Label { + fn from(s: String) -> Self { + let s: &str = &s; + Label(s.into()) + } +} + +impl<'a> From<&'a str> for Label { + fn from(s: &'a str) -> Self { + Label(Rc::from(s)) + } +} + +impl From