-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fail early for
FixedSizeArray
subtypes we can't handle (#99)
Before this PR `collect_as` had to use a type assert on the return value to make sure the return value is of the type requested by the user. This is necessary because of UnionAll types with non-default constraints on their type parameters, such as `FixedSizeVector{T} where {T <: Number}`, because accessing the specific constraint is not currently possible in Julia in a supported way. This change removes the type assert, instead throwing early, as soon as it is recognized that the requested return type is not among the allowed types, which are known-good, in the sense that the return value we produce ends up being of the requested type as expected. Benefits: * a type assert of nonconcrete type is not required any more (those can be expensive) * the throw happens earlier than before Future PRs will possibly apply the same mechanic to some constructors, in addition to `collect_as`.
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 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
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