Skip to content

Commit 5591dce

Browse files
committed
auto merge of #9050 : huonw/rust/unfoldnor, r=thestinger
The `r` is not relevant, since there is only one direction of folding (unlike Haskell).
2 parents b3d50fc + 4c2b480 commit 5591dce

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/libstd/iterator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,26 +1672,26 @@ for Inspect<'self, A, T> {
16721672
}
16731673

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

1681-
impl<'self, A, St> Unfoldr<'self, A, St> {
1681+
impl<'self, A, St> Unfold<'self, A, St> {
16821682
/// Creates a new iterator with the specified closure as the "iterator
16831683
/// function" and an initial state to eventually pass to the iterator
16841684
#[inline]
16851685
pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
1686-
-> Unfoldr<'a, A, St> {
1687-
Unfoldr {
1686+
-> Unfold<'a, A, St> {
1687+
Unfold {
16881688
f: f,
16891689
state: initial_state
16901690
}
16911691
}
16921692
}
16931693

1694-
impl<'self, A, St> Iterator<A> for Unfoldr<'self, A, St> {
1694+
impl<'self, A, St> Iterator<A> for Unfold<'self, A, St> {
16951695
#[inline]
16961696
fn next(&mut self) -> Option<A> {
16971697
(self.f)(&mut self.state)
@@ -2213,7 +2213,7 @@ mod tests {
22132213
}
22142214
}
22152215

2216-
let mut it = Unfoldr::new(0, count);
2216+
let mut it = Unfold::new(0, count);
22172217
let mut i = 0;
22182218
for counted in it {
22192219
assert_eq!(counted, i);

src/test/run-pass/unfoldr-cross-crate.rs renamed to src/test/run-pass/unfold-cross-crate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use std::iterator::*;
1212

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

1616
fn main() {
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525
}
2626

27-
let mut it = Unfoldr::new(0, count);
27+
let mut it = Unfold::new(0, count);
2828
let mut i = 0;
2929
for counted in it {
3030
assert_eq!(counted, i);

0 commit comments

Comments
 (0)