{"id":19162485,"url":"https://github.com/purpleprotocol/hashcow","last_synced_at":"2025-05-07T11:21:23.009Z","repository":{"id":62439966,"uuid":"195840661","full_name":"purpleprotocol/hashcow","owner":"purpleprotocol","description":"A Rust HashMap implementation with copy-on-write keys and values","archived":false,"fork":false,"pushed_at":"2019-09-03T17:40:41.000Z","size":11,"stargazers_count":32,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T00:19:54.773Z","etag":null,"topics":["copy-on-write","data-structure","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purpleprotocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-08T15:32:41.000Z","updated_at":"2024-01-16T20:10:25.000Z","dependencies_parsed_at":"2022-11-01T21:51:14.950Z","dependency_job_id":null,"html_url":"https://github.com/purpleprotocol/hashcow","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purpleprotocol%2Fhashcow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purpleprotocol%2Fhashcow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purpleprotocol%2Fhashcow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purpleprotocol%2Fhashcow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purpleprotocol","download_url":"https://codeload.github.com/purpleprotocol/hashcow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252866118,"owners_count":21816396,"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":["copy-on-write","data-structure","rust"],"created_at":"2024-11-09T09:11:16.641Z","updated_at":"2025-05-07T11:21:22.973Z","avatar_url":"https://github.com/purpleprotocol.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HashCow\n[![Build Status]][travis] [![Discord Badge]][Discord] [![Latest Version]][crates.io] [![Documentation]][docs.rs] \n\nHashCow is a Rust HashMap implementation with copy-on-write keys and values.\n\n---\n\nOriginally built for optimizing the [Purple Protocol](https://github.com/purpleprotocol/purple), this library provides a way to link HashMaps in memory that have duplicate entries. Instead of the duplicate data, it is instead borrowed and it is only cloned when mutation is needed.\n\n### Using HashCow\n```rust\nuse hashcow::{Form, CowHashMap};\n\nlet mut hm: CowHashMap\u003cstr, [u8]\u003e = CowHashMap::new();\n\n// We insert an owned value in the map\nhm.insert_owned(\"key\".to_owned(), vec![1, 2, 3]);\nassert_eq!(hm.entry_form(\u0026\"key\").unwrap(), Form::Owned);\n\n// We now create a clone with borrowed fields\nlet mut hm_clone = hm.borrow_fields();\nassert_eq!(hm_clone.entry_form(\u0026\"key\").unwrap(), Form::Borrowed);\n\n// On mutation, the borrowed entry is cloned\nlet entry = hm_clone.get_mut(\u0026\"key\").unwrap();\n\n// We now mutate the cloned value\n*entry = vec![4, 5, 6];\nassert_eq!(hm_clone.entry_form(\u0026\"key\").unwrap(), Form::Owned);\n\n// The two maps now have different entries for the same key\nassert_eq!(hm.get(\u0026\"key\").unwrap(), \u0026[1, 2, 3]);\nassert_eq!(hm_clone.get(\u0026\"key\").unwrap(), \u0026[4, 5, 6]);\n```\n\n### Contributing\nWe welcome anyone wishing to contribute to HashCow! Check out the [issues section][issues] of the repository before starting out.\n\n### License\n\nHashCow is licensed under the MIT license.\n\n[Build Status]: https://travis-ci.org/purpleprotocol/hashcow.svg?branch=master\n[Discord Badge]: https://img.shields.io/discord/435827644915777536.svg\n[Discord]: https://discord.gg/eGBzyaA\n[travis]: https://travis-ci.org/purpleprotocol/hashcow\n[crates.io]: https://crates.io/crates/hashcow\n[Latest Version]: https://img.shields.io/crates/v/hashcow.svg\n[Documentation]: https://docs.rs/hashcow/badge.svg\n[docs.rs]: https://docs.rs/hashcow\n[issues]: https://github.com/purpleprotocol/hashcow/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurpleprotocol%2Fhashcow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurpleprotocol%2Fhashcow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurpleprotocol%2Fhashcow/lists"}