{"id":28713759,"url":"https://github.com/pradt2/r-ex","last_synced_at":"2025-06-15T00:11:58.297Z","repository":{"id":62783442,"uuid":"562168192","full_name":"pradt2/r-ex","owner":"pradt2","description":"Rust core library extenstions","archived":false,"fork":false,"pushed_at":"2022-11-07T17:59:44.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-17T02:19:00.935Z","etag":null,"topics":["core-library","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","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/pradt2.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}},"created_at":"2022-11-05T14:16:43.000Z","updated_at":"2022-11-05T20:14:26.000Z","dependencies_parsed_at":"2023-01-21T04:36:33.183Z","dependency_job_id":null,"html_url":"https://github.com/pradt2/r-ex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pradt2/r-ex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradt2%2Fr-ex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradt2%2Fr-ex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradt2%2Fr-ex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradt2%2Fr-ex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pradt2","download_url":"https://codeload.github.com/pradt2/r-ex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradt2%2Fr-ex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259901377,"owners_count":22929227,"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":["core-library","rust","rust-lang"],"created_at":"2025-06-15T00:11:57.308Z","updated_at":"2025-06-15T00:11:58.279Z","avatar_url":"https://github.com/pradt2.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# r-ex \n\n![Github](https://img.shields.io/badge/github-pradt2/r_ex-8da0cb?style=flat-square\u0026labelColor=555555\u0026logo=github\")\n![Crates.io](https://img.shields.io/crates/v/r-ex.svg?style=flat-square\u0026color=fc8d62\u0026logo=rust)\n![Codacy grade](https://img.shields.io/codacy/grade/d36aaf2cf1104df5b6f6c5a87f0086c4?style=flat-square)\n![Crates.io](https://img.shields.io/crates/l/r-ex?style=flat-square)\n\nZero-bloat Rust core library extensions that improve the experience \nof using the Rust's type system in everyday tasks.\n\n## Highlights\n\n - **Zero bloat.** Each extension sits behind its own feature flag,\nand no features are enabled by default.\n\n - **Zero risk.** Any feature that may panic or uses unsafe code has\n`-unsafe` added to its feature name.\n\n - **Zero feature interdependencies.** Each extension is standalone,\nand compatible with all the others, so that they can be freely mixed and matched.\n\n - **Zero external dependencies.**\n\n - **No-std.** This project focuses exclusively on the _core_ library.\nWould you like to see a similar project for the _standard_ library? [Let me know.](https://github.com/pradt2/r-ex/issues/new)\n\n - **Stable Rust only.**\n\n - **100% code coverage.**\n\n## Examples\n\n### Copy between arrays\n\nWith r-ex (code never panics):\n\n```rust\nlet mut buf = [0u8; 4];\n\nbuf\n    .carved_mut()?          // automatically select range\n    .copy_from(\u0026[1, 2]);    // type-safe \u0026 size-safe copy never panics\n                            // buf = [1, 2, 0, 0]\n```\n\nWithout r-ex (can panic):\n```rust\nlet mut buf = [0u8; 4];\n\nbuf\n    .get_mut(0..2)?             // explicitly specify range\n    .copy_from_slice(\u0026[1, 2]);  // copy_from_slice panics if sizes mismatch\n                                // buf = [1, 2, 0, 0]\n```\n\n### Write a big-endian value to a buffer at offset\n\nWith `r-ex`:\n```rust\nfn write_big_endian(dest: \u0026mut [u8], offset: usize, val: u32) {\n    dest.carve_mut(offset)? // automatically select range\n        .set_be(val);       // supports big-endian and little-endian values; never panics\n}\n```\n\nWithout `r-ex`:\n```rust\nfn write_big_endian(dest: \u0026mut [u8], offset: usize, val: u32) {\n    dest.get_mut(offset..offset + core::mem::size_of_val(\u0026val))?    // explicitly specify range\n        .copy_from_slice(\u0026val.to_be_bytes())                        // copy_from_slice can panic\n}\n```\n\n## Motivation\nThe Rust core library is awesome. It's clear, concise, non-bloated.\nThis is what we like it for, and we'd all like to keep it this way.\nAnd yet, we often find ourselves writing `utils` or `misc` modules with a handful of small,\ngeneral-purpose extensions to the core library. Sometime these few dozen lines make for\nthe most genius, powerful, or useful code in the whole project.\nTo think that these moments of brilliance and ingenuity sit buried down in some internal module,\nunexposed to the public, is saddening.\n\nThis is where the `r-ex` project comes in. It is home to these little but precious core library\nextensions that would otherwise remain unnoticed.\n\n## Contributor guidelines\n\nPull requests are welcome. Please make sure your contribution adheres to the [Principles](#Principles) section above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradt2%2Fr-ex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpradt2%2Fr-ex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradt2%2Fr-ex/lists"}