When doing orphan checks rust basically ignores what it knows from the bounds: impl Iterator for &mut I where I: Iterator is equivalent to Impl iterator for &mut I from the POV of the orphan rules. They're conservative.
-
-
Replying to @ManishEarth @mountain_ghosts
Actually this particular case isn't one of it being conservative: the stdlib is totally *allowed* to add `impl Iterator for i64`. The orphan rules protect against future impls that could be added as well
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
right; I was wondering where I hadn't already tripped over this with this impl: impl<T, F> Input<T> for F where F: FnMut() -> T
2 replies 0 retweets 0 likes -
-
Replying to @ManishEarth
I guess Fn{,Mut,Once} are special and only implemented for closures, not traits that any other type can implement
2 replies 0 retweets 0 likes -
Replying to @mountain_ghosts
Nope, you can implement them. It's behind a feature flag for ABI reasons but you can implement them.
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @mountain_ghosts
Oh, wait! I misunderstood. You meant that the &mut i64 and FnOnce impl work fine. That's because of #[fundamental]
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @mountain_ghosts
#[fundamental] is what lets you write impls for &T, &mut T, and Box<T> even though they're not from your crate. These three types are fundamental, none others iirc
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @mountain_ghosts
The trade-off here is that the owners of the #[fundamental] type make a commitment never to implement additional traits on the type (unless the trait is added and implemented simultaneously)
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @mountain_ghosts
&mut T is fundamental, so rustc is allowed to assume it will *never* implement FnOnce. However, i64 is not, it could implement Iterator in the future. It won't, but it could.
2 replies 0 retweets 0 likes
That's because FnOnce is fundamental, not &mut T. &mut T being fundamental only affects coherence (it's considered local if T is local)
-
-
Replying to @sgrif @mountain_ghosts
Oh, right, I forgot Fn* were fundamental, I thought it was only Sized
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.