{"id":19143527,"url":"https://github.com/skytable/bagel","last_synced_at":"2025-05-07T00:44:42.175Z","repository":{"id":41563977,"uuid":"510221647","full_name":"skytable/bagel","owner":"skytable","description":"Compile-time stuff and other goodies for rustaceans 🦀","archived":false,"fork":false,"pushed_at":"2022-07-05T15:04:59.000Z","size":39,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"next","last_synced_at":"2025-04-27T04:35:25.050Z","etag":null,"topics":["compile-time","library","rust","rust-lang","rust-library"],"latest_commit_sha":null,"homepage":"https://docs.rs/bagel","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skytable.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-07-04T05:16:34.000Z","updated_at":"2023-04-08T15:39:29.000Z","dependencies_parsed_at":"2022-09-21T13:23:50.513Z","dependency_job_id":null,"html_url":"https://github.com/skytable/bagel","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skytable%2Fbagel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skytable%2Fbagel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skytable%2Fbagel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skytable%2Fbagel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skytable","download_url":"https://codeload.github.com/skytable/bagel/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793562,"owners_count":21805053,"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":["compile-time","library","rust","rust-lang","rust-library"],"created_at":"2024-11-09T07:31:46.887Z","updated_at":"2025-05-07T00:44:42.142Z","avatar_url":"https://github.com/skytable.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🥯 `bagel`: Always baked, never fried\n\n![Rust stable](https://img.shields.io/badge/rust-stable-brightgreen?style=for-the-badge) [![docs.rs](https://img.shields.io/docsrs/bagel?style=for-the-badge)](https://docs.rs/bagel) [![Crates.io](https://img.shields.io/crates/v/bagel?style=for-the-badge)](https://crates.io/crates/bagel) [![Discord](https://img.shields.io/discord/729378001023926282?style=for-the-badge)](https://discord.gg/QptWFdx) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/skytable/bagel/Rust?style=for-the-badge)](https://github.com/skytable/bagel/actions)\n\n`bagel` is a collection of macros and other _things_ that we frequently use at [Skytable](https://github.com/skytable/skytable),\nprimarily to get **work done at compile-time** (because we like it baked :P). This crate contains some of the stuff we use, and we'll add more of the \"magic\" soon.\n\n## Importing\n\n```toml\nbagel = \"0.1\"\n```\n\n## What bagel can do\n\n- `def`: Use the [default declaration syntax](#default-declaration-syntax)\n- `Ctor`: Derive constructors:\n  - Full lifetimes, generics and where clause support\n  - `#[phantom]`: Auto elide `PhantomData` fields\n  - `#[ctor_const]`: Make the constructor a `const fn`\n- `Gtor`: Derive getters:\n  - Full lifetimes, generics and where clause support\n  - Advanced attributes: `#[gtor_const]`, `#[gtor_copy]`, `#[gtor_skip]`, `#[phantom]` and `#[gtor]`\n- `Stor`: Derive setters\n  - Full lifetimes, generics and where clause support\n  - Skip setter with `#[stor_skip]` or `#[phantom]`\n- `Constdef`: Derive constant, compile-time default implementations. See [an example here](#constdef-example)\n\n## Default declaration syntax\n\nThe _default declaration syntax_ is an alternative way to implement defaults for your structs (and enums\nsoon). It looks like this:\n\n1. Use the default trait:\n   ```\n   field: type\n   ```\n2. Use your specified expression:\n   ```\n   field: type = expression\n   ```\n\nHere's an example:\n\n```rust\nuse bagel::def;\n\ndef! {\n    #[derive(Debug)]\n    pub struct MyOven {\n        starting_temperature: u8,\n        increment_temp_by: u8 = 1,\n        oven_name: \u0026'static str = \"my_kitchen_wifi_oven1\",\n        items_to_bake: [\u0026'static str; 4] = [\n            \"bagels\",\n            \"hashbrowns\",\n            \"cookies\",\n            \"pie\",\n        ],\n        people_buffer: Vec\u003cString\u003e = vec![\n            \"one for Jamie\".into(),\n            \"another for Sophie\".into()\n        ],\n    }\n}\n\nlet mut myoven = MyOven::default();\n\nassert_eq!(myoven.starting_temperature, 0);\nassert_eq!(myoven.oven_name, \"my_kitchen_wifi_oven1\");\nassert_eq!(myoven.items_to_bake[3], \"pie\");\nassert_eq!(myoven.people_buffer.len(), 2);\n```\n\n## `Constdef` example\n\n```rust\nuse bagel::Constdef;\n\n#[derive(Constdef)]\nstruct Port {\n    requests: usize,\n    admin: bool,\n}\n\n#[derive(Constdef)]\nstruct PortLogger {\n    ports: [Port; 65536],\n    root_pid: usize,\n}\n\nconst PORT_LOGGER: PortLogger = PortLogger::default();\n\nassert_eq!(PORT_LOGGER.ports[0].requests, 0);\nassert_eq!(PORT_LOGGER.ports[65535].admin, false);\n```\n\n## License\n\nThe `dough` and `bagel` libraries are distributed under the [Apache-2.0 License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskytable%2Fbagel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskytable%2Fbagel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskytable%2Fbagel/lists"}