{"id":17321261,"url":"https://github.com/lambda-fairy/wrapping_macros","last_synced_at":"2025-12-12T13:37:05.128Z","repository":{"id":29628863,"uuid":"33169739","full_name":"lambda-fairy/wrapping_macros","owner":"lambda-fairy","description":":gift_heart: A macro for wrapping arithmetic","archived":false,"fork":false,"pushed_at":"2017-03-12T03:36:45.000Z","size":24,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T10:48:43.215Z","etag":null,"topics":["macros","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MustWin/lovabletech-devops","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambda-fairy.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":"2015-03-31T06:51:57.000Z","updated_at":"2021-10-24T15:15:31.000Z","dependencies_parsed_at":"2022-08-17T20:15:33.594Z","dependency_job_id":null,"html_url":"https://github.com/lambda-fairy/wrapping_macros","commit_stats":null,"previous_names":["lfairy/wrapping_macros"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-fairy%2Fwrapping_macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-fairy%2Fwrapping_macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-fairy%2Fwrapping_macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-fairy%2Fwrapping_macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambda-fairy","download_url":"https://codeload.github.com/lambda-fairy/wrapping_macros/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248907813,"owners_count":21181402,"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":["macros","rust"],"created_at":"2024-10-15T13:36:03.674Z","updated_at":"2025-12-12T13:37:00.081Z","avatar_url":"https://github.com/lambda-fairy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wrapping_macros [![Build Status](https://img.shields.io/travis/lfairy/wrapping_macros.svg)](http://travis-ci.org/lfairy/wrapping_macros) [![Cargo](https://img.shields.io/crates/v/wrapping_macros.svg)](https://crates.io/crates/wrapping_macros)\n\nA macro for wrapping arithmetic.\n\nAny code within a `wrapping! { .. }` block will be transformed as follows:\n\n* `a + b` becomes `a.wrapping_add(b)`. Similarly for `-`, `*`, `/`, `%`, `\u003c\u003c`, `\u003e\u003e`.\n* `a += b` becomes `a = a.wrapping_add(b)`. Similarly for `-=`, `*=`, `/=`, `%=`, `\u003c\u003c=`, `\u003e\u003e=`.\n* `-a` becomes `a.wrapping_neg()`.\n\nSee [this Internals thread][1] for the motivation behind this crate.\n\n[1]: http://internals.rust-lang.org/t/ergonomics-of-wrapping-operations/1756?u=lfairy\n\n**Note:** This crate uses internal compiler APIs, and so requires the Nightly version of Rust.\n\n\n## Cargo\n\nAdd this to your `Cargo.toml`:\n\n```toml\nwrapping_macros = \"*\"\n```\n\n\n## Example\n\n```rust\n#![feature(plugin)]\n#![plugin(wrapping_macros)]\n\nfn main() {\n    let mut sum = 0u8;\n    for x in 0u8..50 {\n        wrapping! {\n            sum += x;\n        }\n    }\n}\n```\n\n\n## Caveats\n\n*   This crate uses unstable APIs, and will only work on Rust Nightly.\n\n*   You cannot nest another macro invocation within a `wrapping!` block. For example, this will not work:\n\n    ```rust\n    let x = 41i32;\n    wrapping! {\n        println!(\"The answer is {}\", x + 1);  //~ ERROR\n    }\n    ```\n\n    Instead, move the macro call out of the block:\n\n    ```rust\n    let x = 41i32;\n    println!(\"The answer is {}\", wrapping! { x + 1 });\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambda-fairy%2Fwrapping_macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambda-fairy%2Fwrapping_macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambda-fairy%2Fwrapping_macros/lists"}