{"id":21046993,"url":"https://github.com/nachoparker/rust-dict","last_synced_at":"2025-05-15T19:31:31.433Z","repository":{"id":31863585,"uuid":"129799184","full_name":"nachoparker/rust-dict","owner":"nachoparker","description":"Exercise crate implementing real associative arrays, also known as dictionaries.","archived":false,"fork":false,"pushed_at":"2021-12-23T14:25:02.000Z","size":14,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-25T19:39:46.496Z","etag":null,"topics":["associative-array","dictionary","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nachoparker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-16T20:07:25.000Z","updated_at":"2020-11-19T12:54:18.000Z","dependencies_parsed_at":"2022-08-07T17:00:16.630Z","dependency_job_id":null,"html_url":"https://github.com/nachoparker/rust-dict","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nachoparker%2Frust-dict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nachoparker%2Frust-dict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nachoparker%2Frust-dict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nachoparker%2Frust-dict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nachoparker","download_url":"https://codeload.github.com/nachoparker/rust-dict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254407331,"owners_count":22066220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["associative-array","dictionary","rust","rust-lang"],"created_at":"2024-11-19T14:34:51.119Z","updated_at":"2025-05-15T19:31:31.149Z","avatar_url":"https://github.com/nachoparker.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-dict\nExercise crate implementing real associative arrays, also known as dictionaries.\n\nThis is a toy example. In practice better use std::collections::HashMap\n\n```\nuse dict::{ Dict, DictIface };\n\n//create a dictionary of strings\nlet mut dict = Dict::\u003cString\u003e::new();\nassert_eq!( dict.is_empty(), true );\nassert_eq!( dict.len(), 0 );\n\n// add an element \"val\" indexed by the key \"key\"\nassert_eq!( dict.add( \"key\".to_string(), \"val\".to_string() ), true );\nassert_eq!( dict.is_empty(), false );\nassert_eq!( dict.len(), 1 );\n\n// keys must be unique\nassert_eq!( dict.add( \"key\".to_string()      , \"other_val\".to_string() ), false );\nassert_eq!( dict.len(), 1 );\nassert_eq!( dict.add( \"other_key\".to_string(), \"other_val\".to_string() ), true );\nassert_eq!( dict.len(), 2 );\n\n// we can iterate just like an array\nfor o in \u0026dict {\n    println!( \"{} - {}\", o.key, o.val );\n}\ndict.iter().for_each( |o| println!( \"{} - {}\", o.key, o.val ) );\n\n// we can access the value by its key string with get()\nassert_eq!( dict.get( \"key\" ).unwrap(), \"val\" );\nassert_eq!( dict.contains_key( \"key\" ), true );\nassert_eq!( dict.remove_key( \"key\" ).unwrap(), \"val\" );\nassert_eq!( dict.contains_key( \"key\" ), false );\n```\n\n[ownyourbits.com](https://ownyourbits.com)\n\n[crates.io](https://crates.io/crates/dict)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnachoparker%2Frust-dict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnachoparker%2Frust-dict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnachoparker%2Frust-dict/lists"}