Conversation
Casting and coercions. Adds custom DST coercions for smart pointers. Otherwise, mostly descriptive, with a few bits of tidying up.
|
Is this the opportunity to discuss possibly allowing numeric types to implicitly coerce when there's no loss of precision, e.g. |
|
@bstrie I think that is a big enough change that it deserves its own RFC |
There was a problem hiding this comment.
I think it would be better to ban such implementations than ignore them.
There was a problem hiding this comment.
That is a reasonable alternative. It would require an ad-hoc check in the type checker though
|
Does this make coercion an special case of casts? Eg, is is true that with the changes every implicit coercion can also be written as an explicit cast? |
|
Will generic integer literals be covered by this RFC? (Perhaps they aren't technically coercion...) I have a little frustration about generic literals with minus sign: fn main() {
for x in std::iter::range_step(3u32, 0, -1) {
println!("{}", x);
}
}I don't like |
|
@nodakai fwiw that's unrelated to generics, a plain |
|
@ben0x539 When you say "generics," you mean the fn main() {
0.f();
} |
|
@nodakai Yeah, I thought you were talking about the |
|
I would like |
|
Merged. Discussion. Tracking. |
Casting and coercions. Adds custom DST coercions for smart pointers. Otherwise, mostly descriptive, with a few bits of tidying up.
Rendered