-
Notifications
You must be signed in to change notification settings - Fork 71
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
Merge confusing World
and WorldInit
derives
#217
Comments
The second code block is much easier to read, but However I'm not sure about this : |
This means that we don't force the library user to make initialization function only sync or async only. It will accept both whether user requires async initialization or not. The point is that user writes exactly the signature he needs, and the generated code takes care itself about any type squating.
The library user won't be able to initialize his But this approach allows us to derive the |
@tyranron separation of
But I see a solution here without using macros. First thing that is bothering me, that #[derive(Debug, cucumber::World)]
struct World {
user: Option<String>,
capacity: usize,
}
#[async_trait(?Send)]
impl cucumber::WorldInit for World {
type Error = Infallible;
async fn new() -> Result<Self, Self::Error> {
Ok(Self { user: None, capacity: 0 })
}
} And finally we can provide blanket impl for #[derive(Debug, Default, cucumber::World)]
struct World {
user: Option<String>,
capacity: usize,
} This should cover majority of the cases, as all async initialisations should happen on |
@ilslv you've misunderstood the idea slightly. We don't touch The idea is just to replace the
The
This is too restrictive assumption. I'd like not to make it as a decision base. |
@tyranron I forgot, that we have
I've looked it up and in
Sure, I wasn't proposing to remove async initialisation entirely, there are suitable use cases for it. I was just making the argument that |
@ilslv well, that was easier than I thougth it would be 🙃 |
Looking at this issue again, I'm not sure whether introducing breaking change like that worth it. I see 2 alternative options:
|
@ilslv it's OK to break here. We won't have |
) - merge `WorldInit` trait into the `World` trait Co-authored-by: Kai Ren <[email protected]>
@ilslv @theredfish what about instead
to have
?
The text was updated successfully, but these errors were encountered: