{"id":28569831,"url":"https://github.com/z2oh/jstd","last_synced_at":"2025-06-25T12:37:01.710Z","repository":{"id":291332936,"uuid":"977260656","full_name":"z2oh/jstd","owner":"z2oh","description":"curated stdlib extension for bootstrapping rust projects","archived":false,"fork":false,"pushed_at":"2025-05-04T00:44:47.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T17:53:49.317Z","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/z2oh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-03T19:37:53.000Z","updated_at":"2025-05-04T00:44:50.000Z","dependencies_parsed_at":"2025-05-03T23:36:23.993Z","dependency_job_id":null,"html_url":"https://github.com/z2oh/jstd","commit_stats":null,"previous_names":["z2oh/jstd"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/z2oh/jstd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z2oh%2Fjstd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z2oh%2Fjstd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z2oh%2Fjstd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z2oh%2Fjstd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/z2oh","download_url":"https://codeload.github.com/z2oh/jstd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z2oh%2Fjstd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261875447,"owners_count":23223338,"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":"2025-06-10T17:30:54.976Z","updated_at":"2025-06-25T12:37:01.667Z","avatar_url":"https://github.com/z2oh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jstd\n\nI've been copying around a `utils.rs` file between small Rust projects for a while now, so I figured it's time to formalize it so I can more easily transfer improvements between projects. This is only intended for bootstrapping new projects; mature projects should explicitly specify the dependencies they use. Custom bootstrapping code is exported as `macros` to ensure syntactic referential transparency.\n\nMost of my projects resemble a CLI tool, and I typically start with the following `main.rs`:\n\n```\n#![allow(dead_code)]\n#![allow(unreachable_code)]\n#![allow(unused_variables)]\n#![allow(unused_imports)]\n\nuse jstd::prelude::*;\n\n// cargo add serde --features derive\nuse serde::{Deserialize, Serialize};\n\n#[derive(Parser, Debug)]\n#[command(version, about)]\nstruct Args {}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    init_log!();\n\n    let args = Args::parse();\n\n    Ok(())\n}\n```\nI couldn't find a way to re-export the `Deserialize`/`Serialize` proc macros through this crate, so `serde` must still be explicitly depended on in consumers.\n\n## Bootstrap macros\n\n### `init_log!`\nWith no parameters, initializes [`colog`](https://docs.rs/colog/latest/colog/) at the default [`LogLevel::Info`](https://docs.rs/log/latest/log/enum.Level.html) for release builds, and [`LogLevel::Trace`](https://docs.rs/log/latest/log/enum.Level.html) for debug builds (by proxy via `cfg!(debug_assertions)`). An optional `$filter_module:expr` string expression can be passed, which will forward the argument to [`env_logger::Builder::filter_module`](https://docs.rs/env_logger/latest/env_logger/struct.Builder.html#method.filter_module); this is useful if any additional dependencies left in logs at the [`Trace`](https://docs.rs/log/latest/log/enum.Level.html) level.\n\n### `benchmark!`\n\nExample usage:\n```\nlet n = 1000000;\nlet output_vec = benchmark!(format!(\"Generating {} random numbers took:\", n), {\n    let mut rng = rand::rng();\n    let mut v = Vec::with_capacity(n);\n    for _ in 0..n {\n        v.push(rng.random::\u003cf32\u003e());\n    }\n    v\n});\n```\nOutputs:\n```\n[*] Generating 1000000 random numbers took: 174.8337ms\n```\n\nBenchmarking is disabled for release builds (by proxy via `cfg!(debug_assertions)`), and the first parameter, `$msg:expr`, is lazily evaluated in a closure to avoid eager evaluation when benchmarking is disabled.\n\n## Binary size\n\nBuilding `main.rs` above using `rustc 1.86.0 (05f9846f8 2025-03-31)` on Windows produces a 2,814.5 KiB debug executable, and a 2,154.5 KiB release executable.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz2oh%2Fjstd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fz2oh%2Fjstd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz2oh%2Fjstd/lists"}