{"id":23975764,"url":"https://github.com/therustmonk/match_cast","last_synced_at":"2025-12-12T14:00:50.262Z","repository":{"id":57636851,"uuid":"69025838","full_name":"therustmonk/match_cast","owner":"therustmonk","description":"Rust match_cast macro implementation","archived":false,"fork":false,"pushed_at":"2016-09-23T13:37:12.000Z","size":3,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T20:06:25.420Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/therustmonk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-23T13:10:17.000Z","updated_at":"2024-03-24T20:29:18.000Z","dependencies_parsed_at":"2022-09-26T20:21:54.729Z","dependency_job_id":null,"html_url":"https://github.com/therustmonk/match_cast","commit_stats":null,"previous_names":["therustmonk/match_cast","deniskolodin/match_cast"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/therustmonk/match_cast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therustmonk%2Fmatch_cast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therustmonk%2Fmatch_cast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therustmonk%2Fmatch_cast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therustmonk%2Fmatch_cast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/therustmonk","download_url":"https://codeload.github.com/therustmonk/match_cast/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therustmonk%2Fmatch_cast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273183228,"owners_count":25059812,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-01-07T06:51:10.220Z","updated_at":"2025-12-12T14:00:44.294Z","avatar_url":"https://github.com/therustmonk.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# match_cast\n\nThis is a minimal crate which implements match through different types.\n\nUsage:\n\n```rust\n#[macro_use]\nextern crate match_cast;\nuse std::panic;\n\nfn main() {\n    let res = panic::catch_unwind(|| {\n        panic!(\"Oh no!\");\n    });\n\n    let any = res.unwrap_err();\n\n    let result = match_cast!( any {\n        val as Option\u003cu8\u003e =\u003e {\n            format!(\"Option\u003cu8\u003e = {:?}\", val)\n        },\n        val as String =\u003e {\n            format!(\"String = {:?}\", val)\n        },\n        val as \u0026'static str =\u003e {\n            format!(\"\u0026'static str = {:?}\", val)\n        },\n    });\n\n    assert_eq!(result.unwrap(), \"\u0026'static str = \\\"Oh no!\\\"\");\n}\n```\n\nTo use pattern there is `match_down` macro:\n\n```rust\n#[macro_use]\nextern crate match_cast;\nuse std::any::Any;\n\nstruct Bar {\n    x: u8,\n}\n\nstruct Foo {\n    x: u8,\n}\n\nfn main() {\n\n    let any: Box\u003cAny\u003e = Box::new(Foo { x: 45 });\n\n    let result = match_down!( any {\n        Bar { x } =\u003e { x },\n        Foo { x } =\u003e { x },\n    });\n\n    assert_eq!(result.unwrap(), 45);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherustmonk%2Fmatch_cast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftherustmonk%2Fmatch_cast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherustmonk%2Fmatch_cast/lists"}