Skip to content
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

Remove redundant lifetime parameters #445

Closed

Conversation

eharcevs
Copy link

Is the 'd lifetime parameter in Container and ContainerAsync redundant? The comment says:

Tracks the lifetime of the client to make sure the container is dropped before the client.

This seems unnecessary since the container already holds a pointer (Box) to the client anyway, which ensures that the container will get dropped before the client. Dropping the redundant lifetime parameter results in a simpler API. wdyt?

@neverchanje
Copy link

neverchanje commented Mar 5, 2023

Ran into a similar issue when I was trying to create a global container for all my tests. Maybe #354 would be helpful for you. Since a related fix was merged #384, we can now use the latest (though unreleased) version. That could probably solve your problem.

testcontainers = { git = "https://github.com/testcontainers/testcontainers-rs.git", rev = "466f503" }
#[macro_use]
extern crate lazy_static;

lazy_static! {
    static ref DOCKER: Cli = Cli::default();
    static ref NODE: Container<'static, MySQL> = DOCKER.run(MySQL::new());
}

@thomaseizinger
Copy link
Collaborator

Thank you for the PR!

I'd like to move the API towards #386 instead which will also remove this lifetime in favor of runtime reference counting.

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.

3 participants