{"id":16153854,"url":"https://github.com/hinto-janai/benri","last_synced_at":"2025-04-06T23:42:32.722Z","repository":{"id":149992746,"uuid":"622675551","full_name":"hinto-janai/benri","owner":"hinto-janai","description":"Convenient macros wrapping the standard library","archived":false,"fork":false,"pushed_at":"2023-05-18T16:25:58.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T01:03:11.792Z","etag":null,"topics":["benri","library","macro","rust","std"],"latest_commit_sha":null,"homepage":"https://docs.rs/benri","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/hinto-janai.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":"2023-04-02T19:52:34.000Z","updated_at":"2023-04-02T19:56:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"436ed006-a32f-47cd-8390-0c6a14a30c32","html_url":"https://github.com/hinto-janai/benri","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/hinto-janai%2Fbenri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Fbenri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Fbenri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Fbenri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hinto-janai","download_url":"https://codeload.github.com/hinto-janai/benri/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569130,"owners_count":20959758,"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":["benri","library","macro","rust","std"],"created_at":"2024-10-10T01:14:44.587Z","updated_at":"2025-04-06T23:42:32.704Z","avatar_url":"https://github.com/hinto-janai.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `benri`\n[![Windows](https://github.com/hinto-janai/benri/actions/workflows/windows.yml/badge.svg)](https://github.com/hinto-janai/benri/actions/workflows/windows.yml) [![macOS](https://github.com/hinto-janai/benri/actions/workflows/macos.yml/badge.svg)](https://github.com/hinto-janai/benri/actions/workflows/macos.yml) [![Linux](https://github.com/hinto-janai/benri/actions/workflows/linux.yml/badge.svg)](https://github.com/hinto-janai/benri/actions/workflows/linux.yml) [![crates.io](https://img.shields.io/crates/v/benri.svg)](https://crates.io/crates/benri) [![docs.rs](https://docs.rs/benri/badge.svg)](https://docs.rs/benri)\n\nConvenient macros wrapping the standard library.\n\nThis library provides convenient `macros!()` around [`std`](https://doc.rust-lang.org/stable/std/) functionality.\n\n## Feature flags\n| Flag             | Purpose |\n|------------------|---------|\n| `log`            | Enable [`log`](https://docs.rs/log) usage in certain places\n\n### Example 1 - Flip a bool:\n```rust\nlet mut a = false;\nflip!(a);\nassert!(a == true);\nflip!(a);\nassert!(a == false);\n```\n\n### Example 2 - Get the current `Instant`:\n```rust\nlet now = now!();\n\nstd::thread::sleep(std::time::Duration::from_secs(1));\n\nassert!(now.elapsed().as_secs() \u003e= 1);\n```\n\n### Example 3 - Get elapsed `Instant` time:\n```rust\nlet now = now!();\n\nstd::thread::sleep(std::time::Duration::from_secs(1));\nassert!(secs!(now)     \u003e= 1);\nassert!(secs_f64!(now) \u003e= 1.0);\nassert!(millis!(now)   \u003e= 1000);\nassert!(micros!(now)   \u003e= 10000);\nassert!(nanos!(now)    \u003e= 100000);\n```\n\n### Example 4 - Sleep a thread:\n```rust\nlet now = now!();\n\n// This sleeps the current thread for 1 second.\nsleep!(1000);\n\nassert!(secs!(now) \u003e= 1);\n```\n\n### Example 5 - Exit _all_ threads:\n```rust\nstd::thread::spawn(|| {\n    mass_panic!();\n}).join().unwrap();\n\n// The program will has already exited.\n// The below statement will never be reached.\nunsafe { /* do bad things */ }\n```\n\n### Example 6 - Send/receive a channel message or `mass_panic!()`:\nThis works with any channel (like [`crossbeam_channel`](https://github.com/crossbeam-rs/crossbeam)) that\nhave the same method names as the `std` channels since the inner macro is calling `.send()` and `.recv()`.\n\n```rust\nlet (tx, rx) = std::sync::mpsc::channel::\u003cu8\u003e();\n\nstd::thread::spawn(move || {\n    send!(tx, 255);\n}).join().unwrap();\n\nassert!(recv!(rx) == 255);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinto-janai%2Fbenri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhinto-janai%2Fbenri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinto-janai%2Fbenri/lists"}