Skip to content

Conversation

epage
Copy link
Contributor

@epage epage commented Apr 20, 2018

The hope is that generics will also make implementing support for #20
easier. If nothing else, they'll give more control to users to implement things how they want.

So when to use each according to The
Book
:

Generics

  • Used when type is going to be function input
  • Can have multiple implementations of trait

Associated types

  • Used when type is going to be a function output, like iterator
    • Avoids need to annotate type
  • Can only have one implementation of trait

BREAKING CHANGE: The Predicate trait's API has changed.

The hope is that generics will also make implementing support for assert-rs#20
easier.

So when to use each according to [The
Book](https://doc.rust-lang.org/book/second-edition/ch19-03-advanced-traits.html#associated-types-versus-generics):

Generics
- Used when type is going to be function input
- Can have multiple implementations of trait

Associated types
- Used when type is going to be a function output, like iterator
  - Avoids need to annotate type
- Can only have one implementation of trait

BREAKING CHANGE: The `Predicate` trait's API has changed.
@epage epage merged commit e1d5b94 into assert-rs:master May 9, 2018
@epage epage deleted the borrow branch May 9, 2018 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant