Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Incorrect handling of map like structures

Aperta
#39 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
tooling

Direzione di ricerca

Inizia dal test applicato in src/tests.rs, in particolare test_option, e riproduci l’errore con il comando di test della libreria. Leggi src/apply.rs intorno alla riga 96 per capire come viene gestito il comando diff che fallisce. Il lavoro è completato quando il roundtrip di HashMap nel test riesce e i casi mirati, array, tupla e option esistenti continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

See the applied test where "map" like structure is tested.

running 4 tests
test tests::test_targeted ... ok
test tests::test_array ... ok
test tests::test_tuple ... ok
test tests::test_option ... FAILED

failures:

---- tests::test_option stdout ----
thread 'tests::test_option' panicked at 'unexpected DiffCommand Value or Remove', src/apply.rs:96:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::test_option

test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'
diff --git a/src/tests.rs b/src/tests.rs
index 082846b..83d117c 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -1,7 +1,9 @@
 use crate as serde_diff;
 use crate::{Apply, Diff, SerdeDiff};
 use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
 use std::fmt::Debug;
+use std::iter::FromIterator;
 
 #[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug, Copy, Clone)]
 struct TestStruct {
@@ -59,6 +61,18 @@ fn test_option() {
         Some(TestStruct { a: 52, b: 32. }),
         Some(TestStruct { a: 42, b: 12. }),
     );
+    roundtrip(
+        HashMap::from_iter([
+            (1, TestStruct { a: 1, b: 1. }),
+            (2, TestStruct { a: 2, b: 2. }),
+            (3, TestStruct { a: 3, b: 3. }),
+        ]),
+        HashMap::from_iter([
+            (1, TestStruct { a: 1, b: 1. }),
+            (3, TestStruct { a: 4, b: 4. }),
+            (4, TestStruct { a: 1, b: 1. }),
+        ]),
+    );
 
     partial(
         Some(TestStruct { a: 5, b: 2. }),
Lingua principale
Rust
Stelle
127
Fork
22
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di amethyst/serde-diff

Tutte le issue di amethyst/serde-diff

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.