[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-73360":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":14,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":45,"readmeContent":46,"aiSummary":47,"trendingCount":16,"starSnapshotCount":16,"syncStatus":48,"lastSyncTime":49,"discoverSource":50},73360,"bon","elastio\u002Fbon","elastio","Next-gen compile-time-checked builder generator, named function's arguments, and more!","https:\u002F\u002Fbon-rs.com",null,"Rust",2047,42,8,27,0,6,15,18,74.4,"Apache License 2.0",false,"master",true,[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"asynchronous","builder","builder-pattern","builders","code-generation","constructor","constructors","data-structures","derive","derive-macro","generator","macro","macros","no-std","no-std-alloc","rust","setter","setter-methods","setters","2026-06-12 04:01:09","\u003Ca href=\"https:\u002F\u002Fbon-rs.com\u002Fguide\u002Foverview\">\n    \u003Cimg\n        src=\"https:\u002F\u002Fbon-rs.com\u002Fbon-home.png\"\n        alt=\"bon home\"\n    \u002F>\n\u003C\u002Fa>\n\n\u003Cdiv align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Felastio\u002Fbon\">\u003Cimg\n        alt=\"github\"\n        src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fgithub-elastio\u002Fbon-228b22?style=for-the-badge&labelColor=555555&logo=github\"\n        height=\"25\"\n    \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcrates.io\u002Fcrates\u002Fbon\">\u003Cimg\n        alt=\"crates.io\"\n        src=\"https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fbon.svg?style=for-the-badge&color=e37602&logo=rust\"\n        height=\"25\"\n    \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fdocs.rs\u002Fbon\u002Flatest\u002Fbon\u002F\">\u003Cimg\n        alt=\"docs.rs\"\n        src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs.rs-bon-3b74d1?style=for-the-badge&labelColor=555555&logo=docs.rs\"\n        height=\"25\"\n    \u002F>\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fdocs.rs\u002Fbon\u002Flatest\u002Fbon\u002F\">\u003Cimg\n        alt=\"docs.rs\"\n        src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMSRV-1.59.0-b83fbf?style=for-the-badge&labelColor=555555&logo=docs.rs\"\n        height=\"25\"\n    \u002F>\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cbr\u002F>\n\n\u003Cdiv align=\"center\">\n    \u003Ctable>\n        \u003Ctbody>\n            \u003Ctr>\n                \u003Ctd>\u003Ca href=\"https:\u002F\u002Fbon-rs.com\u002Fguide\u002Foverview\">📖 Guide Book\u003C\u002Fa>\u003C\u002Ftd>\n                \u003Ctd>Narrative introduction\u003C\u002Ftd>\n            \u003C\u002Ftr>\n            \u003Ctr>\n                \u003Ctd>\u003Ca href=\"https:\u002F\u002Fbon-rs.com\u002Freference\u002Fbuilder\">🔍 API Reference\u003C\u002Fa>\u003C\u002Ftd>\n                \u003Ctd>Attributes API index\u003C\u002Ftd>\n            \u003C\u002Ftr>\n        \u003C\u002Ftbody>\n    \u003C\u002Ftable>\n\u003C\u002Fdiv>\n\n\u003C!-- #region overview -->\n\n# Overview\n\n`bon` is a Rust crate for generating compile-time-checked builders for structs and functions. It also provides idiomatic partial application with optional and named parameters for functions and methods.\n\nIf you wonder \"Why would I use builders?\", see the [motivational blog post](https:\u002F\u002Fbon-rs.com\u002Fblog\u002Fhow-to-do-named-function-arguments-in-rust).\n\n## Function Builder\n\nYou can turn a function with positional parameters into a function with named parameters with `#[builder]`.\n\n```rust\nuse bon::builder;\n\n#[builder]\nfn greet(name: &str, level: Option\u003Cu32>) -> String {\n    let level = level.unwrap_or(0);\n\n    format!(\"Hello {name}! Your level is {level}\")\n}\n\nlet greeting = greet()\n    .name(\"Bon\")\n    .level(24) \u002F\u002F \u003C- setting `level` is optional, we could omit it\n    .call();\n\nassert_eq!(greeting, \"Hello Bon! Your level is 24\");\n```\n\nAny syntax for functions is supported including `async`, fallible, generic functions, `impl Trait`, etc.\n\nMany things are customizable with additional attributes described in the [API reference](https:\u002F\u002Fbon-rs.com\u002Freference\u002Fbuilder), but let's see what else `bon` has to offer.\n\n## Struct Builder\n\nUse `#[derive(Builder)]` to generate a builder for a struct.\n\n```rust\nuse bon::Builder;\n\n#[derive(Builder)]\nstruct User {\n    name: String,\n    is_admin: bool,\n    level: Option\u003Cu32>,\n}\n\nlet user = User::builder()\n    .name(\"Bon\".to_owned())\n    \u002F\u002F `level` is optional, we could omit it here\n    .level(24)\n    \u002F\u002F call setters in any order\n    .is_admin(true)\n    .build();\n\nassert_eq!(user.name, \"Bon\");\nassert_eq!(user.level, Some(24));\nassert!(user.is_admin);\n```\n\n## Method Builder\n\nAssociated methods require `#[bon]` on top of the impl block additionally.\n\n### Method `new`\n\nThe method named `new` generates `builder()\u002Fbuild()` methods.\n\n```rust\nuse bon::bon;\n\nstruct User {\n    id: u32,\n    name: String,\n}\n\n#[bon]\nimpl User {\n    #[builder]\n    fn new(id: u32, name: String) -> Self {\n        Self { id, name }\n    }\n}\n\nlet user = User::builder()\n    .id(1)\n    .name(\"Bon\".to_owned())\n    .build();\n\nassert_eq!(user.id, 1);\nassert_eq!(user.name, \"Bon\");\n```\n\n`#[derive(Builder)]` on a struct generates builder API that is fully compatible with placing `#[builder]` on the `new()` method with a signature similar to the struct's fields (more details on the [Compatibility](https:\u002F\u002Fbon-rs.com\u002Fguide\u002Fbasics\u002Fcompatibility#switching-between-derive-builder-and-builder-on-the-new-method) page).\n\n### Other Methods\n\nAll other methods generate `{method_name}()\u002Fcall()` methods.\n\n```rust\nuse bon::bon;\n\nstruct Greeter {\n    name: String,\n}\n\n#[bon]\nimpl Greeter {\n    #[builder]\n    fn greet(&self, target: &str, prefix: Option\u003C&str>) -> String {\n        let prefix = prefix.unwrap_or(\"INFO\");\n        let name = &self.name;\n\n        format!(\"[{prefix}] {name} says hello to {target}\")\n    }\n}\n\nlet greeter = Greeter { name: \"Bon\".to_owned() };\n\nlet greeting = greeter\n    .greet()\n    .target(\"the world\")\n    \u002F\u002F `prefix` is optional, omitting it is fine\n    .call();\n\nassert_eq!(greeting, \"[INFO] Bon says hello to the world\");\n```\n\nMethods with or without `self` are both supported.\n\n## No Panics Possible\n\nBuilders generated by `bon`'s macros use the typestate pattern to ensure all required parameters are filled, and the same setters aren't called repeatedly to prevent unintentional overwrites. If something is wrong, a compile error will be created.\n\n| ⭐ Don't forget to give our repo a [star on Github ⭐](https:\u002F\u002Fgithub.com\u002Felastio\u002Fbon)! |\n| --------------------------------------------------------------------------------------- |\n\n## What's Next?\n\nWhat you've seen above is the first page of the 📖 Guide Book. If you want to learn more, jump to the [Basics](https:\u002F\u002Fbon-rs.com\u002Fguide\u002Fbasics) section. And remember: knowledge is power 🐱!\n\nFeel free to jump to code and use the `#[builder]` and `#[derive(Builder)]` once you've seen enough docs to get started.\n\nThe [🔍 API Reference](https:\u002F\u002Fbon-rs.com\u002Freference\u002Fbuilder) will help you navigate the attributes once you feel comfortable with the basics of `bon`. Both `#[derive(Builder)]` on structs and `#[builder]` on functions\u002Fmethods have almost identical attributes API, so the documentation for them is common.\n\n## Installation\n\nAdd `bon` to your `Cargo.toml`.\n\n\u003C!-- If you change this, make sure to update `scripts\u002Fsync-version.sh` -->\n\n```toml\n[dependencies]\nbon = \"3.9\"\n```\n\nYou can opt out of `std` and `alloc` cargo features with `default-features = false` for `no_std` environments.\n\nSee [alternatives](https:\u002F\u002Fbon-rs.com\u002Fguide\u002Falternatives) for comparison.\n\n## Getting Help\n\nIf you can't figure something out, consult the docs and maybe use the `🔍 Search` bar on our [docs website](https:\u002F\u002Fbon-rs.com). You may also create an issue or a discussion on the [Github repository](https:\u002F\u002Fgithub.com\u002Felastio\u002Fbon) for help or write us a message on [Discord](https:\u002F\u002Fbon-rs.com\u002Fdiscord).\n\n## Socials\n\n\u003Ctable>\n\u003Ctbody>\n    \u003Ctr>\n        \u003Ctd>\u003Ca href=\"https:\u002F\u002Fbon-rs.com\u002Fdiscord\">Discord\u003C\u002Fa>\u003C\u002Ftd>\n        \u003Ctd>Here you can leave feedback, ask questions, report bugs, etc.\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n## Acknowledgments\n\nThis project was heavily inspired by such awesome crates as [`buildstructor`](https:\u002F\u002Fdocs.rs\u002Fbuildstructor), [`typed-builder`](https:\u002F\u002Fdocs.rs\u002Ftyped-builder) and [`derive_builder`](https:\u002F\u002Fdocs.rs\u002Fderive_builder). This crate was designed with many lessons learned from them.\n\n## Supporters\n\n\u003Cdiv align=\"center\">\n\nBig thanks to `bon`'s current financial supporters ❤️\n\n**Julius Lungys**\\\n\u003Csup>\u003Ccode>$1\u002Fmonth\u003C\u002Fcode>\u003C\u002Fsup>\n\n\u003C\u002Fdiv>\n\n## Past Supporters\n\n\u003Cdiv align=\"center\">\n\nBig thanks to `bon`'s past financial supporters ❤️\n\n[![](https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002Fb0acb844-4b91-461c-95ae-90a601296500)](https:\u002F\u002Fkindness.ai)\\\n[**Kindness**](https:\u002F\u002Fkindness.ai)\n\n**Ethan Skowronski**\n\n\u003C\u002Fdiv>\n\n## License\n\n\u003Csup>\nLicensed under either of \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Felastio\u002Fbon\u002Fblob\u002Fmaster\u002FLICENSE-APACHE\">Apache License, Version\n2.0\u003C\u002Fa> or \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Felastio\u002Fbon\u002Fblob\u002Fmaster\u002FLICENSE-MIT\">MIT license\u003C\u002Fa> at your option.\n\u003C\u002Fsup>\n\n\u003Cbr>\n\n\u003Csub>\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\u003C\u002Fsub>\n\n\u003C!-- #endregion overview -->\n","`bon` 是一个 Rust 项目，用于在编译时生成结构体和函数的构建器，并支持命名参数和部分应用。其核心功能包括为函数和结构体自动生成编译时检查的构建器，允许使用命名参数调用函数，同时支持异步、错误处理、泛型等功能。此外，`bon` 还提供了丰富的自定义选项，如通过属性调整生成代码的行为。此工具非常适合需要提高代码可读性和灵活性的场景，尤其是在处理复杂数据结构或具有多个可选参数的函数时。由于其强大的编译时检查能力，`bon` 能够帮助开发者减少运行时错误，提升开发效率。",2,"2026-06-11 03:45:09","high_star"]