diff --git a/src/rust_api.rs b/src/rust_api.rs index f52f217..6a69cca 100644 --- a/src/rust_api.rs +++ b/src/rust_api.rs @@ -337,6 +337,12 @@ impl FromStr for DnaSequence { } } +impl AsRef<[T]> for DnaSequence { + fn as_ref(&self) -> &[T] { + self.as_slice() + } +} + impl DnaSequence { /// Return canonical isomorphic DNA sequence. /// @@ -778,6 +784,13 @@ mod tests { protein(" an gtnattag \t"); } + #[test] + fn test_as_ref() { + let sequence = dna("ac"); + let nucleotides: &[NucleotideAmbiguous] = sequence.as_ref(); + assert!(nucleotides == &[NucleotideAmbiguous::A, NucleotideAmbiguous::C]); + } + #[cfg(feature = "serde")] #[test] fn test_serde_json() {