-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing owned values to mutable traits
When comparing an owned value with a mutable reference to a trait, of the owned value implements the trait we now allow passing it to a reference to said trait. This means code such as this is now valid: fn example(value: mut ToSomeTrait) {} example(SomeThingThatImplementsToSomeTrait {}) This is valid only at the outer-most "layer" of the type, i.e. passing `Foo` to `mut Array[ToString]` is still invalid. The reason this is sound (or at least should be) for the outer-most type is that the value passed can't be replaced with something of a different type. That is, if we passed `Array[Cat]` to `mut Array[Animal]`, the receiving method could stick a `Dog` in the `Array`. This isn't possible for the outer-most value, so passing `Cat` to `mut Animal` is valid. This fixes #500. Changelog: fixed
- Loading branch information
1 parent
d687283
commit 893cab4
Showing
2 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters