agg: fix typo, add docs

This commit is contained in:
Dmitriy Pleshevskiy 2022-07-28 12:31:59 +03:00
parent e9f77c203f
commit af55a8a31e
6 changed files with 27 additions and 18 deletions

View file

@ -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<R, T>(T, PhantomData<R>);
@ -23,7 +23,7 @@ where
impl<R, T> Aggregate for Sum<R, T>
where
R: std::iter::Sum,
T: Aggregateble<Item = R>,
T: Aggregatable<Item = R>,
{
type Target = R;
@ -32,10 +32,10 @@ where
}
}
impl<R, T> Aggregateble for Sum<R, T>
impl<R, T> Aggregatable for Sum<R, T>
where
R: std::iter::Sum,
T: Aggregateble<Item = R>,
T: Aggregatable<Item = R>,
{
type Item = R;

View file

@ -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<Self::Item>;
}
@ -236,9 +240,10 @@ impl ParseFragment for EString {
}
}
impl Aggregateble for EString {
impl Aggregatable for EString {
type Item = Self;
#[inline]
fn items(self) -> Vec<Self::Item> {
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<Self::Item> {
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<Self::Item> {
vec![self]
}

View file

@ -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<Self::Item> {
vec![self]
}

View file

@ -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<Self::Item> {
vec![self]
}

View file

@ -1,4 +1,4 @@
use crate::core::{Aggregateble, EString, ParseFragment, ToEString};
use crate::core::{Aggregatable, EString, ParseFragment, ToEString};
impl<T> ToEString for Option<T>
where
@ -25,9 +25,9 @@ where
}
}
impl<T> Aggregateble for Option<T>
impl<T> Aggregatable for Option<T>
where
T: Aggregateble,
T: Aggregatable,
{
type Item = T::Item;

View file

@ -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<T, const SEP: char> Aggregateble for SepVec<T, SEP>
impl<T, const SEP: char> Aggregatable for SepVec<T, SEP>
where
T: Aggregateble,
T: Aggregatable,
{
type Item = T::Item;