Skip to content

std: Rename Unfoldr to Unfold. #9050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/libstd/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1672,26 +1672,26 @@ for Inspect<'self, A, T> {
}

/// An iterator which just modifies the contained state throughout iteration.
pub struct Unfoldr<'self, A, St> {
pub struct Unfold<'self, A, St> {
priv f: &'self fn(&mut St) -> Option<A>,
/// Internal state that will be yielded on the next iteration
state: St
}

impl<'self, A, St> Unfoldr<'self, A, St> {
impl<'self, A, St> Unfold<'self, A, St> {
/// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the iterator
#[inline]
pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
-> Unfoldr<'a, A, St> {
Unfoldr {
-> Unfold<'a, A, St> {
Unfold {
f: f,
state: initial_state
}
}
}

impl<'self, A, St> Iterator<A> for Unfoldr<'self, A, St> {
impl<'self, A, St> Iterator<A> for Unfold<'self, A, St> {
#[inline]
fn next(&mut self) -> Option<A> {
(self.f)(&mut self.state)
Expand Down Expand Up @@ -2213,7 +2213,7 @@ mod tests {
}
}

let mut it = Unfoldr::new(0, count);
let mut it = Unfold::new(0, count);
let mut i = 0;
for counted in it {
assert_eq!(counted, i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use std::iterator::*;

// Unfoldr had a bug with 'self that mean it didn't work
// Unfold had a bug with 'self that mean it didn't work
// cross-crate

fn main() {
Expand All @@ -24,7 +24,7 @@ fn main() {
}
}

let mut it = Unfoldr::new(0, count);
let mut it = Unfold::new(0, count);
let mut i = 0;
for counted in it {
assert_eq!(counted, i);
Expand Down