{"id":22258263,"url":"https://github.com/ctron/isx","last_synced_at":"2025-03-25T13:13:50.650Z","repository":{"id":264994402,"uuid":"823092213","full_name":"ctron/isx","owner":"ctron","description":"Traits for checking certain conditions of values","archived":false,"fork":false,"pushed_at":"2024-07-02T12:19:43.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T14:49:53.115Z","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/ctron.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-07-02T12:08:25.000Z","updated_at":"2024-07-07T16:37:15.000Z","dependencies_parsed_at":"2024-11-27T05:14:42.555Z","dependency_job_id":"2c58d775-f240-474e-a7b8-d0970137dc44","html_url":"https://github.com/ctron/isx","commit_stats":null,"previous_names":["ctron/isx"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctron%2Fisx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctron%2Fisx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctron%2Fisx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctron%2Fisx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctron","download_url":"https://codeload.github.com/ctron/isx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467614,"owners_count":20620216,"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-12-03T08:14:18.566Z","updated_at":"2025-03-25T13:13:50.627Z","avatar_url":"https://github.com/ctron.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# is-x\n\nTraits for checking certain conditions of values: is empty? is default?\n\nAlso see: \u003chttps://internals.rust-lang.org/t/traits-for-is-empty-and-or-is-default/21114\u003e\n\n## Examples\n\nFor the `IsDefault` trait:\n\n```rust\nuse isx::prelude::*;\n\nfn test () {\n    assert!(false.is_default());\n    assert!(true.is_not_default());\n}\n```\n\nFor the `IsEmpty` trait:\n\n```rust\nuse isx::prelude::*;\n\nfn test () {\n    assert!(vec![].is_empty());\n    assert!(None::\u003c()\u003e.is_empty());\n}\n```\n\n## Why?\n\nBecause in same cases, it would be great to have a common pattern:\n\n```rust\n\n#[derive(Default, IsDefault, IsEmpty, serde::Serialize, serde::Deserialize)]\nstruct MySubData {\n    // […]\n}\n\n#[derive(Default, serde::Serialize, serde::Deserialize)]\nstruct MyData {\n    #[serde(default, skip_serializing_if = \"IsEmpty::is_empty\")]\n    list: Vec\u003cString\u003e,\n    #[serde(default, skip_serializing_if = \"IsEmpty::is_empty\")]\n    map: HashMap\u003cString, String\u003e,\n    #[serde(default, skip_serializing_if = \"IsEmpty::is_empty\")]\n    optional: Option\u003cString\u003e,\n    \n    #[serde(default, skip_serializing_if = \"IsDefault::is_default\")]\n    flag: bool,\n\n    #[serde(default, skip_serializing_if = \"IsEmpty::is_empty\")]\n    sub_data: MySubData,\n}\n```\n\nHaving that in `std` or `core`, might actually convince people to go for this:\n\n```rust\n#[derive(Default, serde::Serialize, serde::Deserialize)]\nstruct MyData {\n    #[serde(default, skip_serializing_empty)]\n    list: Vec\u003cString\u003e,\n    #[serde(default, skip_serializing_empty)]\n    map: HashMap\u003cString, String\u003e,\n    \n    #[serde(default, skip_serializing_default)]\n    flag: bool,\n}\n```\n\n## ToDo\n\n* Implement a derive for `IsDefault`\n* Implement a derive for `IsEmpty`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctron%2Fisx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctron%2Fisx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctron%2Fisx/lists"}