iterators3 tests dont check if errors are returned correctly

オープン
#2,207 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る

@Lars-Schumann がすでに取り組んでいます。

2025年2月24日 から。

  • #2212 @Lars-Schumann による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
testing-qa

調査の方向性

exercises/18_iterators/iterators3.rs と既存のテストから始め、そこにあるアサーションを issue で説明されているフィルタリングの解決策と比較します。Err バリアントを破棄する実装が失敗するように、演習またはテスト入力を更新し、意図した Result の動作がカバーされていることを確認します。

索引モデルが issue の本文から書いたものです。

説明

A-exercises C-enhancement P-medium

I'm currently doing rustlings and struggled with iterators3 and searched a solution, which i thought i found here.

It implements one of the functions to edit like this:

fn result_with_list() -> Result<Vec<i64>, DivisionError> { 
let numbers = vec![27, 297, 38502, 81];
   let division_results = numbers.into_iter().map(|n| divide(n, 27));
   division_results.filter(|x| x.is_ok()).collect()
}

which compiles and passes the implemented test but this didn't make any sense to me, as this can never return a correct Err variant, at "best" this would return and empty Vec<i64>, if every division returns an Err variant, which is, as far as i understand, not the intended solution.

To remedy this, I would suggest adding test cases to cover this wrong solution, but since the functions that get tested here don't take any parameters, but instead have hard-coded values inside them, this would require changing their signature and passing in the vector of numbers to be divided.

I'm new to rust, so please let me know if this isn't a real issue.

If this is indeed a real issue, I'm happy to suggest an updated version of this exercise.

主要言語
Rust
スター
64.8k
フォーク
11.3k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/rustlings のほかの issue

rust-lang/rustlings の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。