# Pre-RFC: \`fold\_ok\` is composable internal iteration

**URL:** <https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434>\
**Category:** libs\
**Created:** [December 3, 2016, 3:56pm UTC](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434 "2016-12-03T15:56:29Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![bluss](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bluss/32/2264_2.png) [@bluss](https://internals.rust-lang.org/u/bluss)\
**Post date:** [January 7, 2017, 9:28pm UTC](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434/23 "2017-01-07T21:28:22Z")

</div>

This hasn’t moved for some reasons, for example christmas, but also that the following does not compile without additional type hints.

It’s more or less so that any nested use of `try!()` or `?` will have this kind of issue.

Hence my quipping some late night that I wanted a try operator that didn’t convert errors, let’s say `expr=?` for example, that would have to be used inside `fold_ok`'s closure here.

```rust
#![feature(fold_ok)]

use std::io::{BufRead, stdin, self};

fn try_main() -> Result<(), io::Error> {
    let s = stdin();
    let r = s.lock();
    let lines = r.lines().fold_ok(Vec::new(), |mut v, line| {
        v.push(line?);
        Ok(v)
    })?;
    println!("lines: {:?}", lines);
    Ok(())
}

fn main() {
    try_main().unwrap();
}

```

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434)._
