{"id":41575109,"url":"https://github.com/capturecontext/swift-hashed","last_synced_at":"2026-02-05T17:06:18.560Z","repository":{"id":331973265,"uuid":"1130997057","full_name":"CaptureContext/swift-hashed","owner":"CaptureContext","description":"Hashable wrapper type and a set of explicit hashing strategies","archived":false,"fork":false,"pushed_at":"2026-01-09T10:16:33.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-24T17:21:15.502Z","etag":null,"topics":["foundation","hashable","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/CaptureContext.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-09T10:15:26.000Z","updated_at":"2026-01-09T10:16:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/CaptureContext/swift-hashed","commit_stats":null,"previous_names":["capturecontext/swift-hashed"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CaptureContext/swift-hashed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-hashed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-hashed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-hashed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-hashed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaptureContext","download_url":"https://codeload.github.com/CaptureContext/swift-hashed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-hashed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28886909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T21:06:44.224Z","status":"ssl_error","status_checked_at":"2026-01-29T21:06:42.160Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["foundation","hashable","swift"],"created_at":"2026-01-24T08:14:10.367Z","updated_at":"2026-02-03T14:06:45.176Z","avatar_url":"https://github.com/CaptureContext.png","language":"Swift","readme":"# swift-hashed\n\n[![CI](https://github.com/CaptureContext/swift-hashed/actions/workflows/ci.yml/badge.svg)](https://github.com/CaptureContext/swift-hashed/actions/workflows/ci.yml) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FCaptureContext%2Fswift-hashed%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/CaptureContext/swift-hashed) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FCaptureContext%2Fswift-hashed%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/CaptureContext/swift-hashed)\n\nHashable wrapper type and a set of explicit hashing strategies.\n\n## Table of Contents\n\n  - [Motivation](#motivation)\n  - [Features](#features)\n    - [Predefined comparators](#predefined-comparators)\n  - [Installation](#installation)\n    - [Basic](#basic)\n    - [Recommended](#recommended)\n  - [License](#license)\n\n## Motivation\n\nSwift strongly encourages `Hashable`, especially when working with collections, diffing, and identity-based logic.\n\nIn practice, however, hashing often becomes problematic at API boundaries:\n\n- values erased to `any`\n- reference types without stable identity\n- types you don’t own\n- generic code that cannot add `Hashable` constraints\n- contexts where different hashing strategies are required\n\nThis is especially visible when working with KeyPath-based APIs, where generic composition frequently destroys compile-time `Hashable` conformance.\n\n## Features\n\n`Hashed` is a lightweight `Hashable` container that lets you define equality explicitly, while keeping call sites terse.\n\n### Predefined hashers\n\nChoose how two values should be compared using a `Hashed.Hasher`:\n\n#### Automatic\n\nThe `detectHashable` comparator attempts to cast values to `any Hashable` and compare them using native `hash(into hasher: inout Swift.Hasher)` method:\n\n```swift\n.detectHashable(fallback: Hasher = .dump)\n```\n\nIf hashable cast is not possible, the provided `fallback` hasher is used.\n\n#### Building blocks\n\n- `.empty` – nothing is combined into `Swift.Hasher``\n- `.custom((Value, inout Swift.Hasher) -\u003e Void)` – full control\n- `.dump` – hashes the textual `dump()` output\n\n#### Hashable-driven\n\n- `.defaultHashable` – equivalent to using native `hash(into hasher: Swift.Hasher)` method\n\n#### Property-based\n\nThe `property` hashable hashes values by a derived hashable projection:\n\n```swift\n.property(\\.someHashableProperty)\n.property { String(reflecting: $0) }\n```\n\n- `.objectID` – hash reference identity (only when `Value: AnyObject`)\n\n#### Error convenience\n\nThe `.localizedDescription` hasher is equivalent to `.property(\\.localizedDescription)`.\n\nIt is typically most useful as a fallback, for example:\n\n```swift\n.detectHashable(fallback: .localizedDescription)\n```\n\n#### Concurrency escape hatches\n\n- `.uncheckedSendable((Value) -\u003e any Hashable)`\n\n  _A `property`-style comparator for non-sendable projections_\n\n- `.uncheckedSendable((Value, inout Swift.Hasher) -\u003e Void)`\n\n  _A `custom`-style comparator for non-sendable values_\n\n\u003e [!NOTE]\n\u003e\n\u003e _Most users should prefer `.detectHashable()` or `.property`_ hashers\n\n## Installation\n\n### Basic\n\nYou can add Hashed to an Xcode project by adding it as a package dependency.\n\n1. From the **File** menu, select **Swift Packages › Add Package Dependency…**\n2. Enter [`\"https://github.com/capturecontext/swift-hashed\"`](https://github.com/capturecontext/swift-hashed) into the package repository URL text field\n3. Choose products you need to link them to your project.\n\n### Recommended\n\nIf you use SwiftPM for your project structure, add Hashed to your package file.\n\n```swift\n.package(\n  url: \"https://github.com/capturecontext/swift-hashed.git\",\n  .upToNextMinor(from: \"0.0.1\")\n)\n```\n\nor via HTTPS\n\n```swift\n.package(\n  url: \"https://github.com/capturecontext/swift-hashed.git\",\n  .upToNextMinor(\"0.0.1\")\n)\n```\n\nDo not forget about target dependencies:\n\n```swift\n.product(\n  name: \"Hashed\",\n  package: \"swift-hashed\"\n)\n```\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-hashed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapturecontext%2Fswift-hashed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-hashed/lists"}