{"id":20667068,"url":"https://github.com/lu-zero/cow_struct","last_synced_at":"2025-10-12T05:02:42.356Z","repository":{"id":139397057,"uuid":"332830057","full_name":"lu-zero/cow_struct","owner":"lu-zero","description":"Derive per-field Cow Structures","archived":false,"fork":false,"pushed_at":"2021-01-25T20:21:10.000Z","size":3,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T13:17:04.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lu-zero.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":"2021-01-25T17:37:58.000Z","updated_at":"2021-03-24T08:08:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b547697-4650-4294-bbc9-0dac31baadb6","html_url":"https://github.com/lu-zero/cow_struct","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/lu-zero%2Fcow_struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu-zero%2Fcow_struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu-zero%2Fcow_struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu-zero%2Fcow_struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lu-zero","download_url":"https://codeload.github.com/lu-zero/cow_struct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242856023,"owners_count":20196360,"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":[],"created_at":"2024-11-16T19:42:49.096Z","updated_at":"2025-10-12T05:02:37.321Z","avatar_url":"https://github.com/lu-zero.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# derive CowStruct\n\nThis crate consists in a procedural macro derive that provides a struct that is Cow and the impl to create one from the target struct.\n\n## Usage\n\n``` rust\n    use cow_struct::CowStruct;\n\n    #[derive(Debug, Default, CowStruct)]\n    struct A {\n        a: LargeStruct,\n        b: OtherLargeStruct,\n        c: AnotherOne,\n        ...\n        z: YetAnother,\n    }\n\n    fn evaluation(cfg: \u0026Config, state: \u0026mut CowA) -\u003e usize { ... }\n\n    fn foo() {\n        // original struct\n        let a = A::new();\n\n        let mut val = 0;\n        // similar struct, with all the fields set as Cow::Borrowed from a;\n        let mut cow = a.to_cow();\n        let mut cow_out = cow.to_cow();\n        let mut v_max = usize::min();\n        for cfg in inputs() {\n            // it is going to change cow, a remains untouched\n            let val = evaluation(cfg, \u0026mut cow);\n\n            // let's pick the best candidate\n            for candidate in candidates_b(val) {\n                let mut cow2 = cow.to_cow();\n                let v = evaluation_b(candidate, \u0026mut cow2);\n                if v \u003e v_max {\n                    v_max = v;\n                    cow_out = cow2;\n                }\n            }\n        }\n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu-zero%2Fcow_struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flu-zero%2Fcow_struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu-zero%2Fcow_struct/lists"}