Skip to content

refactor: replaced string-typed file to paths#287

Merged
varex83 merged 7 commits intomainfrom
pb/string_to_path
Mar 23, 2026
Merged

refactor: replaced string-typed file to paths#287
varex83 merged 7 commits intomainfrom
pb/string_to_path

Conversation

@PoulavBhowmick03
Copy link
Collaborator

Closes #283

.map(|(i, (filepath, private_key))| KeyFile {
private_key,
filename,
filename: filepath.to_string_lossy().to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we store Path in KeyFile instead of String?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was stuck between using String and PathBuf, because of having to use the to_string_lossy in the errors where the filename is used, and also because it needs a separate .display, but PathBuf makes more sense, as the KeyFile construction gets simpler and is the correct type. Going with PathBuf

Copy link
Collaborator

@iamquang95 iamquang95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the lint check

Copy link
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

.join("src/keystore/testdata")
.to_string_lossy()
.to_string();
let testdata_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/keystore/testdata");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to use "src/keystore/testdata" as literal, but for safety prefer chaining .join calls.

@varex83 varex83 merged commit 115d6c1 into main Mar 23, 2026
11 checks passed
@varex83 varex83 deleted the pb/string_to_path branch March 23, 2026 17:27
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.

Replace string-typed file paths with PathBuf / impl AsRef<Path>

4 participants