Use serde-cs::CS with StarOr to reduce the logic duplication

This commit is contained in:
Kerollmops 2022-06-02 11:14:46 +02:00
parent 10d3b367dc
commit 64b5b2e1f8
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
3 changed files with 20 additions and 14 deletions

View file

@ -49,7 +49,10 @@ impl<T: FromStr> FromStr for StarOr<T> {
/// Extracts the raw values from the `StarOr` types and
/// return None if a `StarOr::Star` is encountered.
pub fn fold_star_or<T>(content: impl IntoIterator<Item = StarOr<T>>) -> Option<Vec<T>> {
pub fn fold_star_or<T, O>(content: impl IntoIterator<Item = StarOr<T>>) -> Option<O>
where
O: FromIterator<T>,
{
content
.into_iter()
.map(|value| match value {