-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Transaction type on Either type #2097
Conversation
51c0e5e
to
1f7ca62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simplify this a lot if we reuse the existing Either
type from the either crate and implement our Tx traits for that type
@mattsse
With direct Either enum (clean):
While reusing either crate saves implementation code, it significantly impacts usability. Unless we make the inner field public (breaking encapsulation) or implement our own enum directly(as it is currently implemented here), we lose the clean pattern matching that makes working with sum types handy and easy to use and clean. |
1f7ca62
to
cc748bd
Compare
What do you mean? https://docs.rs/either is exactly the same as what you defined |
Yep, it is the same to take advantage of the ergonomics of sum types.
would require an indirection layer, assuming inner field is defined as a public:
if defined as private would be even less ergonomic. Alright, i will change this to use a wrapper type with the inner field public |
What would be a good name here?
What do you think? @DaniPopes @mattsse |
You shouldn't need a wrapper type at all, all the traits you want to implement are defined in this repository so you can just implement them on the foreign type |
cc748bd
to
786a21a
Compare
Done !! |
786a21a
to
6367f04
Compare
6367f04
to
5509c19
Compare
Motivation
See #2051
Solution
A new module called either is added, this is useful to handle different transactions types
as it implements
Transaction
trait. The Either type here is a bit similar to this, however a custom one might be easier to customize.PR Checklist