expected &{integer}, found integer
〇 assert_eq!(m1.get("b"), Some(&3)); ✕ assert_eq!(m1.get("b"), Some(3)); ✕ assert_eq!(m1.get("b"), &3); ✕ assert_eq!(m1.get("b"), 3); 〇 assert_eq!(m1.get("c"), None);
PS > cargo run --example ch05_04_hash_map Compiling ex05 v0.1.0 (\rustbook\ch05\ex05)
error[E0308]: mismatched types --> examples\ch05_04_hash_map.rs:11:5 | 11 | assert_eq!(m1.get("b"), Some(3)); | ^^^^^^^^^^^^^^^^^^^^^^ | expected &{integer}, found integer | = note: expected type `std::option::Option<&{integer}>` found type `std::option::Option<{integer}>`
error[E0308]: mismatched types --> examples\ch05_04_hash_map.rs:12:5 | 12 | assert_eq!(m1.get("b"), &3); | ^^^^^^^^^^^^^^^^^^^ | expected enum `std::option::Option`, found &{integer} | help: try using a variant of the expected type: `Some(*right_val)` | = note: expected type `std::option::Option<&{integer}>` found type `&{integer}`
error[E0308]: mismatched types --> examples\ch05_04_hash_map.rs:13:5 | 13 | assert_eq!(m1.get("b"), 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | expected enum `std::option::Option`, found integer | = note: expected type `std::option::Option<&{integer}>` found type `{integer}`
教科書は、
- 作者: κeen,河野達也,小松礼人
- 出版社/メーカー: 技術評論社
- 発売日: 2019/05/08
- メディア: 単行本(ソフトカバー)
- この商品を含むブログを見る