Skip to content
Snippets Groups Projects
Commit c35c1d89 authored by Martin Larralde's avatar Martin Larralde
Browse files

Add `From<Vec<_>>` and `Default` traits to `EncodedSequence`

parent b0a68a5e
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,6 @@ use typenum::Unsigned;
use super::Backend;
use crate::abc::Alphabet;
use crate::abc::Symbol;
use crate::pli::scores::StripedScores;
use crate::pwm::ScoringMatrix;
use crate::seq::StripedSequence;
......
......@@ -92,6 +92,12 @@ impl<A: Alphabet> AsRef<[<A as Alphabet>::Symbol]> for EncodedSequence<A> {
}
}
impl<A: Alphabet> Default for EncodedSequence<A> {
fn default() -> Self {
Self::new(Vec::new())
}
}
impl<A: Alphabet> Display for EncodedSequence<A> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
for c in self.data.iter() {
......@@ -108,6 +114,12 @@ impl<A: Alphabet> FromStr for EncodedSequence<A> {
}
}
impl<A: Alphabet> From<Vec<A::Symbol>> for EncodedSequence<A> {
fn from(data: Vec<A::Symbol>) -> Self {
Self::new(data)
}
}
impl<'a, A: Alphabet> IntoIterator for &'a EncodedSequence<A> {
type Item = &'a A::Symbol;
type IntoIter = std::slice::Iter<'a, A::Symbol>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment