{"id":23792408,"url":"https://github.com/sunsided/use-with","last_synced_at":"2026-02-02T21:37:17.776Z","repository":{"id":268558222,"uuid":"904750699","full_name":"sunsided/use-with","owner":"sunsided","description":"Provides resource management utilities inspired by Kotlin's 'use' function and C#'s 'using' block, ensuring proper utilization and disposal of resources in Rust.","archived":false,"fork":false,"pushed_at":"2025-06-24T08:43:01.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T08:43:53.680Z","etag":null,"topics":["disposable","rust","using"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/use-with","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/sunsided.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}},"created_at":"2024-12-17T13:37:19.000Z","updated_at":"2025-06-24T08:43:05.000Z","dependencies_parsed_at":"2024-12-17T14:31:22.289Z","dependency_job_id":"001ade10-8785-4fc0-91a9-42bb557523b0","html_url":"https://github.com/sunsided/use-with","commit_stats":null,"previous_names":["sunsided/use-with"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sunsided/use-with","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fuse-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fuse-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fuse-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fuse-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/use-with/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fuse-with/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29020919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T18:51:31.335Z","status":"ssl_error","status_checked_at":"2026-02-02T18:49:20.777Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["disposable","rust","using"],"created_at":"2025-01-01T18:31:33.857Z","updated_at":"2026-02-02T21:37:17.744Z","avatar_url":"https://github.com/sunsided.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use_with\n\n[![codecov](https://codecov.io/gh/sunsided/use-with/graph/badge.svg?token=Ex1Ok4n9yd)](https://codecov.io/gh/sunsided/use-with)\n\nProvides resource management utilities, ensuring that resources are properly utilized\nand subsequently dropped, similar to patterns found in other programming languages like Kotlin's `use` function\nand C#'s `using` block.\n\nThis module offers two primary functions:\n- `use_with`: Executes a closure synchronously, consuming the resource.\n- `use_with_async`: Executes an asynchronous closure, consuming the resource.\n\nThese functions facilitate safe and efficient resource handling, ensuring that resources are properly utilized\nand dropped, even in asynchronous contexts.\n\n# Features\n- **Synchronous Resource Management:** The `use_with` function allows for synchronous operations on resources,\n  ensuring that resources are properly utilized and dropped after the operation completes.\n\n- **Asynchronous Resource Management:** The `use_with_async` function facilitates asynchronous operations on resources,\n  ensuring that resources are properly utilized and dropped after the asynchronous operation completes.\n\n# Usage\nTo use these functions, the `Use` trait is auto-implemented for your resource types; simply call the appropriate method:\n\n```rust\nuse use_with::Use;\n\nstruct Resource;\n\nimpl Resource {\n    fn new() -\u003e Self {\n        Resource\n    }\n}\n\n#[test]\nfn it_works() {\n    let resource = Resource::new();\n    let result = resource.use_with(|res| {\n        // Perform operations with `res`, return anything.\n        42\n    });\n\n    // The resource is now dropped.\n    assert_eq!(result, 42);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fuse-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fuse-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fuse-with/lists"}