첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ HashMap 구조체의 get 메소드를 사용해 키 존재 여부를 구하는 방법을 보여준다.

 

▶ 예제 코드 (RS)

use std::collections::HashMap;

fn main()
{
    let mut hashmap = HashMap::new();

    hashmap.insert("A", 30);
    hashmap.insert("B", 50);

    match hashmap.get("D")
    {
        Some(value) => println!("D={}", value),
        None => println!("D 키는 존재하지 않습니다.")
    }
}
728x90
그리드형(광고전용)
Posted by icodebroker
,