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

Extend TempFile #202

Open
JonathanWoollett-Light opened this issue Aug 30, 2023 · 1 comment
Open

Extend TempFile #202

JonathanWoollett-Light opened this issue Aug 30, 2023 · 1 comment

Comments

@JonathanWoollett-Light
Copy link
Contributor

A common use for TempFile is to get a unique path where a file can be created, modified and removed.

The current approach to this:

let file = TempFile::new();
let path = file.as_path();
drop(file);
// Use the path

This is awkward and introduces a race condition in that another call to mkstemp in another test after this test deletes the file could return the same path.

it would be useful to offer a better mechanism to support this.

@andreeaflorescu
Copy link
Member

Hmm, interesting, I was thinking that creating a file should be more of a rare pattern, and typically you would work with references. I was expecting this pattern to only be used in things like main.rs. What is the functionality for which this is used?

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

No branches or pull requests

2 participants