http-rs / http-rs/http-types

Wrong `From` implementation.

Open
#524 1 comment 6 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
209
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Hi all,

I just noticed a crash on my application when calling `if let Ok(mime: Mime) = x.try_into()` beacuse of the `unwrap()` in: https://github.com/http-rs/http-types/blob/v2.12.0/src/mime/mod.rs#L131

I think `TryFrom` implementation would be nice to have as would avoid this kind of errors.

I know I can use the `FromStr` (that what I'm doing after I discovered the issue), but the I still think it is worth to have the `TryFrom`

I can come with a PR.

Contributor guide

Open the contributing guide

Research direction

Start in src/mime/mod.rs at the From implementation around line 131, then compare it with the existing FromStr behavior. Add the requested TryFrom conversion so invalid MIME input returns an error instead of panicking; done means the conversion no longer relies on unwrap().

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.