missing/confusing documentation of behavior of str::{floor_char_boundary, ceil_char_boundary} when index > len
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
作業内容は、標準ライブラリのソースコードにある str::floor_char_boundary と str::ceil_char_boundary のドキュメントコメントの修正です。両方のメソッドを見つけ、ceil_char_boundary の既存コメントを読んでください。そのコメントでは、インデックスが末尾を超えている場合の結果は文字列の長さだとしたうえで、その値を「index より小さくない」と呼んでおり、矛盾しています。範囲外の場合の同じ動作を述べる一文を floor_char_boundary に追加し、ceil_char_boundary の注記は言い換えてください。両方のドキュメントが矛盾なくクランプの動作を説明し、ドキュメントテストが引き続き通ることで完了です。
索引モデルが issue の本文から書いたものです。
説明
Location (URL)
https://doc.rust-lang.org/1.99.1/std/primitive.str.html#method.floor_char_boundary
https://doc.rust-lang.org/1.99.1/std/primitive.str.html#method.ceil_char_boundary
Summary
The documentation for str::floor_char_boundary doesn't say what happens if the requested index is greater than the string length: will it panic? return the input value? clamp to the string length?
It appears the result will always be clamped to a valid byte index, i.e. if the input is past the end, then the return value will be the string length. This means that truncating a string with &s[..s.floor_char_boundary(i)] will do the expected thing (and never panic).
Additionally, str::ceil_char_boundary does document its behavior in this case, but that documentation somewhat contradicts itself:
/// Finds the closest `x` not below `index` where [`is_char_boundary(x)`] is `true`.
///
/// If `index` is greater than the length of the string, this returns the length of the string.
This is confusing because "the length of the string" is a possible return value that could be below index. Perhaps there's a better way to write that?
- 主要言語
- Rust
- スター
- 121k
- フォーク
- 17.3k
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 534
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust のほかの issue
-
`char::EscapeDebug` displays a char it's already yielded対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンA-fmt A-iterators A-str C-bug I-prioritize regression-from-stable-to-stable T-libs
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
rust-lang/rust#165504 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
relnotes relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
0xPlaygrounds/rig#3176 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
packaging
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
SalomonAvila/memtop#23 ·
メンテナーはふだん 1 日以内に返信
-
Anthropic provider: 400 on tools.N.custom.name after tool_search adds web.run (name contains a dot)オープンarea:install area:mcp area:state area:tui os:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
area:core
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信