From 6939abfe2fcd8e08b1d9c23a182fe0e8727c8957 Mon Sep 17 00:00:00 2001 From: Douwe Schulte Date: Wed, 15 Nov 2023 21:20:57 +0100 Subject: [PATCH] Added more conversions --- src/complex_peptide.rs | 18 ++++++++++++++++++ src/linear_peptide.rs | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/src/complex_peptide.rs b/src/complex_peptide.rs index ec2438f..779ea33 100644 --- a/src/complex_peptide.rs +++ b/src/complex_peptide.rs @@ -587,6 +587,24 @@ impl ComplexPeptide { } } +impl From for ComplexPeptide +where + Item: Into, +{ + fn from(value: Item) -> Self { + Self::Singular(value.into()) + } +} + +impl FromIterator for ComplexPeptide +where + Item: Into, +{ + fn from_iter>(iter: T) -> Self { + Self::Singular(LinearPeptide::from(iter)) + } +} + /// A list of found modifications, with the newly generated ambiguous lookup alongside the index into the chars index from where parsing can be continued type UnknownPositionMods = (usize, Vec, AmbiguousLookup); /// If the text is recognised as a unknown mods list it is Some(..), if it has errors during parsing Some(Err(..)) diff --git a/src/linear_peptide.rs b/src/linear_peptide.rs index 69dd3ce..075527a 100644 --- a/src/linear_peptide.rs +++ b/src/linear_peptide.rs @@ -485,6 +485,15 @@ where } } +impl FromIterator for LinearPeptide +where + Item: Into, +{ + fn from_iter>(iter: T) -> Self { + Self::from(iter) + } +} + /// One block in a sequence meaning an aminoacid and its accompanying modifications #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SequenceElement {