From af55a8a31e983bed0a4183b6ab0c85f63f4dc45d Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Thu, 28 Jul 2022 12:31:59 +0300 Subject: [PATCH] agg: fix typo, add docs --- src/agg/sum.rs | 8 ++++---- src/core.rs | 15 +++++++++++---- src/std/bool.rs | 5 +++-- src/std/number.rs | 5 +++-- src/std/option.rs | 6 +++--- src/structs/sep_vec.rs | 6 +++--- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/agg/sum.rs b/src/agg/sum.rs index 0318665..f7f0dea 100644 --- a/src/agg/sum.rs +++ b/src/agg/sum.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use crate::{Aggregate, Aggregateble, EString, ParseFragment}; +use crate::{Aggregatable, Aggregate, EString, ParseFragment}; #[derive(Debug, PartialEq, Eq)] struct Sum(T, PhantomData); @@ -23,7 +23,7 @@ where impl Aggregate for Sum where R: std::iter::Sum, - T: Aggregateble, + T: Aggregatable, { type Target = R; @@ -32,10 +32,10 @@ where } } -impl Aggregateble for Sum +impl Aggregatable for Sum where R: std::iter::Sum, - T: Aggregateble, + T: Aggregatable, { type Item = R; diff --git a/src/core.rs b/src/core.rs index 189b6c4..2d6bd74 100644 --- a/src/core.rs +++ b/src/core.rs @@ -123,9 +123,13 @@ pub trait Aggregate { fn agg(self) -> Self::Target; } -pub trait Aggregateble { +// TODO: add example +/// Trait to represent structures that can iterate values for the aggregator. +pub trait Aggregatable { + /// The type of the elements being iterated over. type Item; + /// Returns Vec of aggregatable values fn items(self) -> Vec; } @@ -236,9 +240,10 @@ impl ParseFragment for EString { } } -impl Aggregateble for EString { +impl Aggregatable for EString { type Item = Self; + #[inline] fn items(self) -> Vec { vec![self] } @@ -258,9 +263,10 @@ impl ToEString for String { } } -impl Aggregateble for String { +impl Aggregatable for String { type Item = Self; + #[inline] fn items(self) -> Vec { vec![self] } @@ -280,9 +286,10 @@ impl<'a> ToEString for &'a str { } } -impl<'a> Aggregateble for &'a str { +impl<'a> Aggregatable for &'a str { type Item = Self; + #[inline] fn items(self) -> Vec { vec![self] } diff --git a/src/std/bool.rs b/src/std/bool.rs index fe02c7f..876f29b 100644 --- a/src/std/bool.rs +++ b/src/std/bool.rs @@ -1,4 +1,4 @@ -use crate::core::{Aggregateble, EString, ParseFragment, ToEString}; +use crate::core::{Aggregatable, EString, ParseFragment, ToEString}; use crate::error::{Error, Reason}; impl ParseFragment for bool { @@ -19,9 +19,10 @@ impl ToEString for bool { } } -impl Aggregateble for bool { +impl Aggregatable for bool { type Item = Self; + #[inline] fn items(self) -> Vec { vec![self] } diff --git a/src/std/number.rs b/src/std/number.rs index 4c6a982..2afae8c 100644 --- a/src/std/number.rs +++ b/src/std/number.rs @@ -1,4 +1,4 @@ -use crate::core::{Aggregateble, EString, ParseFragment, ToEString}; +use crate::core::{Aggregatable, EString, ParseFragment, ToEString}; use crate::error::{Error, Reason}; #[doc(hidden)] @@ -19,9 +19,10 @@ macro_rules! from_env_string_numbers_impl { } } - impl Aggregateble for $ty { + impl Aggregatable for $ty { type Item = Self; + #[inline] fn items(self) -> Vec { vec![self] } diff --git a/src/std/option.rs b/src/std/option.rs index bea98b5..be2e648 100644 --- a/src/std/option.rs +++ b/src/std/option.rs @@ -1,4 +1,4 @@ -use crate::core::{Aggregateble, EString, ParseFragment, ToEString}; +use crate::core::{Aggregatable, EString, ParseFragment, ToEString}; impl ToEString for Option where @@ -25,9 +25,9 @@ where } } -impl Aggregateble for Option +impl Aggregatable for Option where - T: Aggregateble, + T: Aggregatable, { type Item = T::Item; diff --git a/src/structs/sep_vec.rs b/src/structs/sep_vec.rs index 59c0eb7..166fc89 100644 --- a/src/structs/sep_vec.rs +++ b/src/structs/sep_vec.rs @@ -1,7 +1,7 @@ //! Contains the implementations to vec type //! -use crate::core::{Aggregateble, EString, ParseFragment, ToEString}; +use crate::core::{Aggregatable, EString, ParseFragment, ToEString}; use std::fmt::Write; /// Wrapper for ``Vec`` to split string by a separator (`SEP`). @@ -92,9 +92,9 @@ where } } -impl Aggregateble for SepVec +impl Aggregatable for SepVec where - T: Aggregateble, + T: Aggregatable, { type Item = T::Item;