add `From<GlobError> for io::Error` impl

Open
#64 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Start by locating GlobError and its existing error-formatting implementation, then compare it with the requested io::Error conversion in the issue. Verify that the conversion preserves the existing contextual message and that functions returning io::Error can use glob errors with ?. Confirm the relevant test suite passes.

Written by the indexing model from the issue text.

Description

The conversion I would suggest is:

impl From<GlobError> for io::Error {
    fn from(err: GobError) -> io::Error {
        io::Error::new(err.error.kind(), err)
    }
}

This will keep the "pretty context" so that glob errors keep printing as:

"attempting to read `{}` resulted in an error: {}",
self.path.display(),
self.error

Which is already very ergonomic.

I can do this if you OK it 😄

Benefits / Justification

The glob error is already essentially an io::Error with a bit of additional context. This will allow functions that return io::Error can use glob with ? directly which incurs (basically) no performance issues.

Dominant language
Rust
Stars
597
Forks
97
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/glob

All issues in rust-lang/glob

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.