News for hackers. Stuff that matters.
Re:Functional Language Features in Rust – Iterators and Clos... by curun1r on Tuesday March 07, 2017 @07:14PM (#13816603)
Under the "Improving our I/O Project" section, there's this little paragraph:

  It would be nice if we could use ? on the Option
  returned from next, but ? only works with Result
  values currently. Even if we could use ? on Option
  like we can on Result, the value we would get would
  be borrowed, and we want to move the String from
  the iterator into Config.
It seems remiss to not mention that Option/Result have combinators/adapters too, no?

  let search = match args.next() {
      Some(arg) => arg,
      None => return Err("Didn't get a search string"),
  };
becomes:

  let search = args.next().ok_or("Didn't get a search string")?;
I'm not the most fluent in Rust, so please tell me whether the above two snippets are not equivalent in some way.

It might actually be a nice segue into a page on the combinators of Option and Result, since functional-style Rust seems to benefit from liberal use of them.

Re:Functional Language Features in Rust – Iterators and Clos... by steveklabnik on Tuesday March 07, 2017 @07:20PM (#13816645)
This is a great suggestion! I'm on mobile right now, but I'll file an issue when I get home, or if you feel like it, please do!
Re:Functional Language Features in Rust – Iterators and Clos... by pitaj on Tuesday March 07, 2017 @09:27PM (#13817325)
Please don't quote with code blocks.
Re:Functional Language Features in Rust – Iterators and Clos... by curun1r on Tuesday March 07, 2017 @10:47PM (#13817729)
Umm...If I don't quote the entire code snippet, I'll end up with just the indented lines being quoted...the joys of HN formatting.
Re:Functional Language Features in Rust – Iterators and Clos... by pitaj on Wednesday March 08, 2017 @02:38AM (#13818646)
I was speaking with reference to "It would be nice..." which you quoted using a pre/code block (prepending four spaces). Please only use that for actual code, and use `>` at the start of the line to signify a quote, like so:

> Umm...If I don't quote the entire code snippet, I'll end up with just the indented lines being quoted...the joys of HN formatting.

This allows for responsive formatting on different screen sizes, and is especially beneficial for mobile users.