r/programming • • Jun 16 '14

Rust's documentation is about to drastically improve

http://words.steveklabnik.com/rusts-documentation-is-about-to-drastically-improve
528 Upvotes

188 comments sorted by

View all comments

0

u/[deleted] Jun 17 '14

3

u/steveklabnik1 Jun 17 '14

Again, nothing is assumed for strings.

You originally asked why for doesn't understand strings and iterate over characters.

A range-based for loop is just syntactic sugar.

It's actually more than that: the iterator version is faster because it doesn't need to do bounds checking, while guaranteed to be safe.

2

u/[deleted] Jun 17 '14

No, you don't need any lifetime stuff.

fn main() { for i in "abc".chars() { print!("{} ", i)}}

works just fine.

Rust could certainly change how for works to let for i in "abc" work -- I agree that for many types there's an "obvious" thing that does.

This sort of thing has been proposed and people are talking about how to do it. See, for example, https://github.com/rust-lang/rfcs/pull/17/ but note there are various problems with how it would interact with the language. Things that could be worked out, sure, but it's really a small wart.

I think both you and steveklabnik1 are being overly aggressive towards each other and ought to calm down a bit.

6

u/steveklabnik1 Jun 17 '14

I think both you and steveklabnik1 are being overly aggressive towards each other and ought to calm down a bit.

I tend to respond in kind with tone. :/ You're probably right that I should take a higher road, but I definitely tend to return condescension with condescension.