Future of StatusCode::as_str
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 重構
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- rust
- 領域
- networking
研究方向
從 StatusCode::as_str 方法開始,閱讀所引用的 PR #380、#436 和 #466,以及 #443 上連結的討論。比較保留、變更、棄用或移除該方法的理由,包括其二進位大小成本;完成表示專案已就方向達成共識,並有可執行的後續工作。
由索引模型根據 Issue 內容生成。
描述
I wanted to write-up some thoughts on the future direction for the StatusCode::as_str method. The as_str method returns the numeric part of the status code as a string slice. So, StatusCode::OK.as_str() returns "200", and StatusCode::NOT_FOUND.as_str() returns "404", and so forth. This works for all StatusCodes, from 100-999. Since the StatusCode only stores an integer, there's no field to actually borrow the string from, so it is in reality returning a &'static str, even though the method signature doesn't expose that.
There have been several PRs filed to make that part of the signature (that is, change from fn as_str(&self) -> &str to fn as_str(&self) -> &'static str) (#380 #436 #466).
I've personally questioned the value of the method in it's entirety:
I was thinking that perhaps we just axe
StatusCode::as_str, because really, how useful can it be? There's theDisplayimpl to get a string, and if you want a fast path for some common status codes, a user can just do that manually (hyper has a fast path forHTTP/1.1 200 OK, for instance).
That comment was prompted as I wondered about the cost of including all the static strings in the binary, when certainly most applications will never need them. Because I don't see value in the method, I've held off from changing it return a &'static str. Instead, I've thought we may just want to deprecate it and chop it for 1.0.
However, I realize I could be wrong, and not considering a large use case for this method. If so, we can just merge one of the PRs and carry on. If I have overlooked something, hopefully we can collect the reasons why to keep the method, with some details about the value it provides versus the cost of having a bunch of extra strings in the binary for everyone.
- 主要語言
- Rust
- 星號
- 1.4k
- 分支
- 387
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
hyperium/http 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
-
難度 3/5 1-2 天 新手友好度 52/100
-
難度 4/5 3-5 天 新手友好度 45/100
-
難度 3/5 1-2 天 新手友好度 62/100
-
難度 3/5 1-2 天 新手友好度 58/100
相似的 Issue
-
area:docs documentation good first issue priority:medium
難度 1/5 1 小時以內 新手友好度 78/100
維護者通常 1 天內回覆
-
feature
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Bug]: streamed Responses API flex_unavailable error maps to 500 InternalServerError instead of 429未關閉llm translation
難度 2/5 1 小時以內 新手友好度 85/100
BerriAI/litellm#49736 · 1 則留言 ·
維護者通常 1 天內回覆
-
question
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
field-report
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆