Skip to content

「第十二章」代码清单 12-52 断言测试用例错误 #131

@micooz

Description

@micooz

页码与行数

  • 代码清单 12-52 第 8 行

代码错误

#![feature(proc_macro_hygiene)]

#[test]
fn test_hashmap() {
    let hm = hashmap!{ "a": 1, "b": 2 };
    assert_eq!(hm["a"], 1);
    let hm = hashmap!{ "a" => 1, "b" => 2, "c" => 3 };
    assert_eq!(hm["d"], 4); // 此处断言不通过
}

Rust版本

$ rustc -V
rustc 1.34.0-nightly (d17318011 2019-02-07)

错误信息

thread 'test_hashmap' panicked at 'no entry found for key', src/libcore/option.rs:1038:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions