diff --git a/src/element/sequence.rs b/src/element/sequence.rs index 4c73b559..788cd2b0 100644 --- a/src/element/sequence.rs +++ b/src/element/sequence.rs @@ -131,6 +131,12 @@ impl AsRef for Sequence { } } +impl AsRef<[Element]> for Sequence { + fn as_ref(&self) -> &[Element] { + self.elements.as_slice() + } +} + // This is more efficient than Sequence::new(), which will iterate over and convert each value to // an Element for better ergonomics. impl From> for Sequence { diff --git a/src/types/list.rs b/src/types/list.rs index cd59c46e..8aa2d3a0 100644 --- a/src/types/list.rs +++ b/src/types/list.rs @@ -52,6 +52,12 @@ impl AsRef for List { } } +impl AsRef<[Element]> for List { + fn as_ref(&self) -> &[Element] { + self.0.as_ref() + } +} + // Allows `for element in &list {...}` syntax impl<'a> IntoIterator for &'a List { type Item = &'a Element; diff --git a/src/types/sexp.rs b/src/types/sexp.rs index b860bb89..31478c93 100644 --- a/src/types/sexp.rs +++ b/src/types/sexp.rs @@ -52,6 +52,12 @@ impl AsRef for SExp { } } +impl AsRef<[Element]> for SExp { + fn as_ref(&self) -> &[Element] { + self.0.as_ref() + } +} + // Allows `for element in &sexp {...}` syntax impl<'a> IntoIterator for &'a SExp { type Item = &'a Element;