Skip to content

Commit

Permalink
Small doc improvements (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebffischer authored Oct 17, 2024
1 parent e4ddc02 commit 79d788a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/object/vector/rep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,24 @@ pub struct IntoIterableRefNames {
iter: Box<dyn Iterator<Item = Option<usize>>>,
}

pub struct RepIterableNames<'a> {
pub struct IterableNames<'a> {
names: &'a [Character],
na_name: &'a Character,
iter: &'a mut Box<dyn Iterator<Item = Option<usize>>>,
}

impl IntoIterableRefNames {
pub fn iter(&mut self) -> RepIterableNames<'_> {
pub fn iter(&mut self) -> IterableNames<'_> {
let names = &self.names[..];
RepIterableNames {
IterableNames {
names,
na_name: &self.na_name,
iter: &mut self.iter,
}
}
}

impl<'a> Iterator for RepIterableNames<'a> {
impl<'a> Iterator for IterableNames<'a> {
type Item = &'a Character;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -390,9 +390,8 @@ impl<T: Clone + Default> Rep<T> {
}
}

/// Get an `Option<RepTypeIntoIterableValues<T>>` which in turn can be converted into an iterator over
/// references to the values.
/// The `None` variant is returned if the `Rep<T>` is not named.
/// Get an `IntoIterableValues<T>` which in turn can be converted into an iterator over
/// references to the values (`&T`).
///
/// Directly getting an iterator is not possible due to lifetime issues.
pub fn values_ref(&self) -> IntoIterableRefValues<T> {
Expand All @@ -406,8 +405,9 @@ impl<T: Clone + Default> Rep<T> {
}
}

/// Get an `RepTypeIntoIterableValues<T>` which in turn can be converted into an iterator over
/// references to the names.
/// Get an `Option<IntoIterableRefNames>` which in turn can be converted into an iterator over
/// references to the names (`&String`).
/// None is returned when no names exist.
///
/// Directly getting an iterator is not possible due to lifetime issues.
pub fn names_ref(&self) -> Option<IntoIterableRefNames> {
Expand All @@ -422,8 +422,8 @@ impl<T: Clone + Default> Rep<T> {
}
}

/// Get an `RepTypeIntoIterablePairs<T>` which in turn can be converted into an iterator over
/// pairs of references (&name, &value).
/// Get an `IntoIterablePairs<T>` which in turn can be converted into an iterator over
/// pairs of references (`(&String, &T)`).
///
/// Directly getting an iterator is not possible due to lifetime issues.
pub fn pairs_ref(&self) -> IntoIterableRefPairs<T> {
Expand All @@ -444,6 +444,7 @@ impl<T: Clone + Default> Rep<T> {
}
}

/// Iterate over (owned) pairs of names and values (`(String, T)`).
pub fn iter_pairs(&self) -> IterablePairs<T> {
match self.clone() {
Rep::Subset(values, _, maybe_naming) => {
Expand Down

0 comments on commit 79d788a

Please sign in to comment.