Skip to content

Commit 08d2dba

Browse files
committed
chore: proper readme for introduction
1 parent 3a85adf commit 08d2dba

File tree

5 files changed

+89
-3
lines changed

5 files changed

+89
-3
lines changed

.github/assets/footer.png

195 KB
Loading

.github/assets/header.png

1.97 MB
Loading

LICENSE renamed to LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2025 Rust Uzbekistan
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Rust Uzbekistan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
1-
# maydon
2-
📝 | Field enum generation for a struct
1+
<p align="center">
2+
<img src=".github/assets/header.png" alt="Rust Uzbekistan's {Maydon}">
3+
</p>
4+
5+
<p align="center">
6+
<h3 align="center">Field enum generation for struct.</h3>
7+
</p>
8+
9+
<p align="center">
10+
<img align="center" src="https://img.shields.io/github/languages/top/rust-lang-uz/maydon?style=flat&logo=nixos&logoColor=5277C3&labelColor=ffffff&color=ffffff" alt="Top Used Language">
11+
<a href="https://t.me/rustlanguz"><img align="center" src="https://img.shields.io/badge/Chat-grey?style=flat&logo=telegram&logoColor=ffffff&labelColor=242424&color=242424" alt="Telegram Chat"></a>
12+
<a href="https://github.com/rust-lang-uz/maydon/actions/workflows/test.yml"><img align="center" src="https://img.shields.io/github/actions/workflow/status/rust-lang-uz/maydon/test.yml?style=flat&logo=github&logoColor=ffffff&labelColor=242424&color=242424" alt="Test CI"></a>
13+
</p>
14+
15+
## Motivation
16+
17+
Upon writing some rusty code for CLI config management, I simply declared a struct like this:
18+
19+
```rust
20+
#[derive(Debug, Serialize, Deserialize)]
21+
pub struct Config {
22+
pub url: String,
23+
pub port: u16,
24+
pub database_url: String,
25+
pub threads: u16,
26+
}
27+
```
28+
29+
Also, in order to have set function with proper typed selection, I declared another enum named `Field`:
30+
31+
```rust
32+
pub enum Field {
33+
Url,
34+
Port,
35+
Database,
36+
Unknown,
37+
Threads,
38+
}
39+
```
40+
41+
The thing is, I wanted to automate creation of enum generation. Ordinary macros wouldn't be a good viable solution, so I wrote maydon from ground up. I might be missing something or prequisites, but this is what I came up with:
42+
43+
```rust
44+
use maydon::Maydon;
45+
46+
#[derive(Maydon)]
47+
#[field_name = "Selector"]
48+
pub struct Config {
49+
pub url: String,
50+
pub port: u16,
51+
}
52+
53+
// The macro should generate:
54+
fn main() {
55+
let _ = Selector::Url;
56+
let _ = Selector::Port;
57+
let _ = Selector::Unknown;
58+
}
59+
```
60+
61+
## License
62+
63+
This project is licensed under the MIT or Apache-2.0 license - see the [LICENSE-MIT](LICENSE-MIT) or [LICENSE-APACHE](LICENSE-APACHE) file for details.
64+
65+
<p align="center">
66+
<img src=".github/assets/footer.png" alt="Rust Uzbekistan's {Maydon}">
67+
</p>

0 commit comments

Comments
 (0)