These are chat archives for rust-lang/rust

26th
Jun 2015
Ihor Kaharlichenko
@kaharlichenko
Jun 26 2015 15:10
according to the array docs IntoIterator is implemented for sizes up to 31 inclusive, I wonder how does this code work then?
let a: [u32; 50] = [0xDEADBEEF; 50];
let b = a.into_iter();
Peter Atashian
@retep998
Jun 26 2015 17:58
@madkinder That's actually being invoked on &[T] instead of &[T; N].
Ihor Kaharlichenko
@kaharlichenko
Jun 26 2015 17:59
@retep998 I know, but how is it converted? The conversion rules are not documented.
and if you put 7 instead of 50, for example, then it will happily use implementation from [T; 7]
Peter Atashian
@retep998
Jun 26 2015 20:16
@madkinder Fixed size arrays will implicitly convert to slices.
Ihor Kaharlichenko
@kaharlichenko
Jun 26 2015 20:33
@retep998 could you please point to the doc that says that?
the only thing I could find is explanation of Deref trait that makes the compiler implicitly cast pointers. But I couldn't find anything about implicitly casting arrays to slices.
Peter Atashian
@retep998
Jun 26 2015 20:45
@madkinder The work in progress TURPL covers that http://cglab.ca/~abeinges/blah/turpl/_book/conversions.html#coercions
Ihor Kaharlichenko
@kaharlichenko
Jun 26 2015 20:47
@retep998 thank you a ton! that's really helpful. I wish it was publicly available in Rust book in the first place