Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

String -> PathBuf roundup #660

Open
maackle opened this issue Nov 22, 2018 · 1 comment · May be fixed by #1701
Open

String -> PathBuf roundup #660

maackle opened this issue Nov 22, 2018 · 1 comment · May be fixed by #1701
Labels
good first issue Good for newcomers

Comments

@maackle
Copy link
Member

maackle commented Nov 22, 2018

There are several functions that take Strings as arguments and then use them as file paths. The container_api::Configuration has several examples of this. Let's clean up some of these in one big PR.

@timotree3
Copy link
Collaborator

I'm working on this and should have a PR up today.

willemolding pushed a commit that referenced this issue Oct 7, 2019
Resolves #660

This change is valuable because you may obtain a path that
contains non-utf8 data and try to use it with these APIs,
but if these APIs take Strings, you have to lossily convert it
and you can't operate on those files.

The main non-obvious change as a result of this effort are changes like:

```
format!("using path: \'{}\'", some_string_path)
```
to
```
format!("using path: {:?}", some_pathbuf)
```

these result in a change from single quotes to double quotes.

The alternative substition is

```
format!("using path: \'{}\'", some_pathbuf.to_string_lossy())
```
this has the advantage of preserving single-quotes, but has the
disadvantage of requiring an extra allocation over the more
efficient Debug-impl of PathBuf.

There are existing instances in the code where the later approach is
used, it may be worth changing all instances to use the same choice.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants