oxidecomputer / oxidecomputer/omicron
Omicron's `Error::internal_error` could be more general
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
This was raised by @ahl in the following context:
maybe change `internal_error`?
Maybe these should accept impl ToString ? or AsRef<str>
Originally posted by @ahl in https://github.com/oxidecomputer/omicron/pull/4874#discussion_r1465720421
I have often found myself creating an internal error by calling foo.to_string() here. That causes an allocation at the call site, passes a reference from which a new allocation is made, and then throws away the original. It might be nice to take something like impl ToString and call to_string() internally.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Omicron's Error::internal_error definition and reviewing its call sites, especially those that call foo.to_string() before passing the value. Determine how the error can accept a more general string-convertible input, then confirm that callers avoid the unnecessary allocation and existing error behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100