devnagari 0.1.0

Code in Devanagari (Hindi/Sanskrit) — type aliases, macros, and keyword translation for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# devnagari

[![Crates.io](https://img.shields.io/crates/v/devnagari)](https://crates.io/crates/devnagari)
[![Documentation](https://docs.rs/devnagari/badge.svg)](https://docs.rs/devnagari)
[![License: MIT](https://img.shields.io/crates/l/devnagari)](LICENSE)

**Write Rust in Devanagari — Hindi and Sanskrit both supported.**

Devanagari Unicode characters have been valid Rust identifiers since Rust 1.53. This crate builds on that foundation to give you:

- **`देव! { }`** — a proc-macro that translates Devanagari *keywords* (`कार्य`, `यदि`, `मिलान`…) into Rust keywords so the compiler accepts them
- **Type aliases**`पूर्णांक` for `i32`, `पाठ` for `String`, `सूची<T>` for `Vec<T>`, and 25+ more
- **Macro aliases**`छापो!` for `println!`, `स्वरूप!` for `format!`, and more
- **Extension traits**`.लम्बाई()`, `.रिक्त_है()`, `.योग()`, `.छानो()` and 30+ methods on standard types
- **Sanskrit vocabulary** — classical Paninian/Vedic alternatives: `वर्ण` (`char`), `सूत्र` (`String`), `अङ्क` (`i32`), number constants `एक``कोटि`, and Sanskrit keyword synonyms

---

## Installation

```toml
[dependencies]
devnagari = "0.1"
```

Then import the prelude:

```rust
use devnagari::prelude::*;
```

---

## How `देव! { }` works

Rust does not accept Devanagari as *keywords* (`fn`, `let`, `if`, etc.) but it does accept them as *identifiers*. `देव! { }` is a proc-macro that walks the token stream of its input and substitutes Devanagari keyword identifiers with their Rust equivalents before the compiler sees them.

```
कार्य → fn      मान → let      यदि → if      मिलान → match
```

Everything that is **not** a keyword — your function names, variable names, struct fields, type names — passes through completely unchanged. So `अर्जुन`, `क्षेत्रफल`, `विद्यार्थी` remain exactly as you wrote them.

```rust
use devnagari::prelude::*;

देव! {
    कार्य जोड़(क: पूर्णांक, ख: पूर्णांक) -> पूर्णांक {
        क + ख          // क, ख are your identifiers — untouched
    }                  // पूर्णांक is a type alias — also untouched
}
// expands to: fn जोड़(क: i32, ख: i32) -> i32 { क + ख }
```

### Block form vs attribute form

**Block form** — wrap multiple items:

```rust
देव! {
    संरचना बिंदु { x: दशमलव, y: दशमलव }

    क्रियान्वयन बिंदु {
        कार्य नया(x: दशमलव, y: दशमलव) -> स्वप्रकार {
            स्वप्रकार { x, y }
        }
    }
}
```

**Attribute form** — apply to a single item:

```rust
#[देव_attr]
संरचना बिंदु { x: दशमलव, y: दशमलव }

#[देव_attr]
क्रियान्वयन बिंदु {
    कार्य दूरी(&स्व, अन्य: &स्वप्रकार) -> दशमलव {
        मान dx = स्व.x - अन्य.x;
        मान dy = स्व.y - अन्य.y;
        (dx * dx + dy * dy).sqrt()
    }
}
```

**ASCII aliases** — for editors that struggle with Devanagari macro names:

```rust
dev! { ... }       // same as देव! { }
#[dev_attr]        // same as #[देव_attr]
```

---

## Hindi keywords

These are the primary keyword mappings using everyday Hindi vocabulary.

| Devanagari        | Rust       | अर्थ                   |
|-------------------|------------|------------------------|
| `कार्य`           | `fn`       | function / work        |
| `मान`             | `let`      | value / binding        |
| `परिवर्तनीय`     | `mut`      | mutable                |
| `यदि`             | `if`       | if                     |
| `अन्यथा`          | `else`     | otherwise              |
| `जबतक`            | `while`    | as long as             |
| `प्रत्येक`        | `for`      | for each               |
| `चक्र`            | `loop`     | cycle / loop           |
| `मिलान`           | `match`    | match / compare        |
| `वापस`            | `return`   | back / return          |
| `रुको`            | `break`    | stop                   |
| `जारी`            | `continue` | continue               |
| `में`             | `in`       | in                     |
| `संरचना`          | `struct`   | structure              |
| `गणना`            | `enum`     | enumeration            |
| `विशेषता`         | `trait`    | characteristic         |
| `क्रियान्वयन`    | `impl`     | implementation         |
| `जहाँ`            | `where`    | where                  |
| `सार्वजनिक`      | `pub`      | public                 |
| `खंड`             | `mod`      | module / section       |
| `उपयोग`           | `use`      | use                    |
| `प्रकार`          | `type`     | type                   |
| `स्थिरांक`       | `const`    | constant               |
| `स्थायी`          | `static`   | static                 |
| `स्व`             | `self`     | self                   |
| `स्वप्रकार`      | `Self`     | Self (type)            |
| `पितृ`            | `super`    | parent / super         |
| `मूल`             | `crate`    | crate                  |
| `जैसे`            | `as`       | as (cast / alias)      |
| `अतुल्य`          | `async`    | asynchronous           |
| `प्रतीक्षा`      | `await`    | wait / await           |
| `चल`              | `move`     | move closure           |
| `गतिशील`          | `dyn`      | dynamic dispatch       |
| `असुरक्षित`       | `unsafe`   | unsafe                 |
| `बाह्य`           | `extern`   | external               |
| `सत्य`            | `true`     | true                   |
| `असत्य`           | `false`    | false                  |
| `संदर्भ_बंध`     | `ref`      | reference binding      |

---

## Sanskrit keywords

Classical Sanskrit alternatives that can be used instead of or alongside the Hindi keywords above. Both sets work inside the same `देव! { }` block — mix freely.

| Sanskrit          | Rust       | अर्थ                              |
|-------------------|------------|-----------------------------------|
| `कर्म`            | `fn`       | action / deed (Bhagavad Gita)     |
| `नियत`            | `let`      | fixed / assigned                  |
| `विकारी`          | `mut`      | subject to modification           |
| `चेत्`            | `if`       | if (classical conditional)        |
| `यावत्`           | `while`    | as long as (classical)            |
| `आवर्तन`          | `loop`     | repetition / cycling              |
| `विराम`           | `break`    | pause / stop                      |
| `अनुवर्तन`       | `continue` | following / proceeding            |
| `निवृत्ति`       | `return`   | returning / cessation             |
| `कृते`            | `for`      | for the purpose of (`impl T for U`)|
| `रचना`            | `struct`   | creation / structure              |
| `लक्षण`           | `trait`    | characteristic (Paninian grammar) |
| `साधन`            | `impl`     | means / implementation            |
| `ध्रुव`           | `const`    | fixed / pole star                 |
| `शाश्वत`          | `static`   | eternal / unchanging              |
| `यत्र`            | `where`    | where (classical locative)        |
| `आत्म`            | `self`     | self (Vedantic concept)           |
| `आत्मप्रकार`     | `Self`     | Self type                         |
| `इव` / `यथा`     | `as`       | like / as (Sanskrit comparative)  |
| `असमकालिक`       | `async`    | asynchronous                      |
| `प्रतीक्षण`      | `await`    | act of waiting                    |
| `गमन`             | `move`     | movement                          |
| `अरक्षित`         | `unsafe`   | unprotected                       |
| `बाह्यिक`         | `extern`   | external                          |
| `अंश`             | `mod`      | part / portion                    |

---

## Type aliases

Import via `use devnagari::prelude::*`.

### Hindi type aliases

| Type alias          | Rust type         | अर्थ                    |
|---------------------|-------------------|-------------------------|
| `पूर्णांक`          | `i32`             | integer (default)       |
| `दीर्घपूर्णांक`    | `i64`             | long integer            |
| `महापूर्णांक`      | `i128`            | 128-bit integer         |
| `लघुपूर्णांक`      | `i8`              | small integer           |
| `मध्यपूर्णांक`     | `i16`             | medium integer          |
| `सूचकांक`           | `isize`           | pointer-sized integer   |
| `अष्टांक`           | `u8`              | unsigned 8-bit          |
| `बाइट`              | `u8`              | byte (I/O alias)        |
| `षोडशांक`           | `u16`             | unsigned 16-bit         |
| `अचिह्नित`          | `u32`             | unsigned 32-bit         |
| `दीर्घाचिह्नित`    | `u64`             | unsigned 64-bit         |
| `आकार`              | `usize`           | size / index type       |
| `दशमलव`             | `f64`             | decimal (default float) |
| `लघुदशमलव`          | `f32`             | single-precision float  |
| `पाठ`               | `String`          | text (owned)            |
| `अक्षर`             | `char`            | character               |
| `बूलियन`            | `bool`            | boolean                 |
| `शून्य`             | `()`              | unit / void             |
| `सूची<T>`           | `Vec<T>`          | list / vector           |
| `कोश<K, V>`         | `HashMap<K, V>`   | dictionary              |
| `क्रमकोश<K, V>`    | `BTreeMap<K, V>`  | ordered dictionary      |
| `समुच्चय<T>`        | `HashSet<T>`      | set                     |
| `द्विसिरासूची<T>`  | `VecDeque<T>`     | double-ended queue      |
| `विकल्प<T>`         | `Option<T>`       | optional value          |
| `फल<T, E>`          | `Result<T, E>`    | result / outcome        |
| `पिटारा<T>`         | `Box<T>`          | heap box                |
| `साझा<T>`           | `Arc<T>`          | shared (thread-safe)    |
| `आरसी<T>`           | `Rc<T>`           | reference-counted       |
| `कोशिका<T>`         | `Cell<T>`         | interior mutable cell   |
| `परिवर्तकोशिका<T>` | `RefCell<T>`      | runtime borrow cell     |
| `ताला<T>`           | `Mutex<T>`        | mutex lock              |
| `पाठताला<T>`        | `RwLock<T>`       | read-write lock         |

### Sanskrit type aliases

| Type alias          | Rust type         | अर्थ                          |
|---------------------|-------------------|-------------------------------|
| `अङ्क`              | `i32`             | digit/numeral (Paninian)      |
| `महाङ्क`            | `i64`             | great number                  |
| `राशि`              | `f64`             | quantity (Sanskrit math term) |
| `लघुराशि`           | `f32`             | small quantity                |
| `वर्ण`              | `char`            | phoneme/letter (Paninian)     |
| `सूत्र`             | `String`          | thread / formula / aphorism   |
| `सत्यासत्य`         | `bool`            | true-or-false (dvandva)       |
| `परिमाण`            | `usize`           | measure / quantity            |
| `श्रेणी<T>`         | `Vec<T>`          | series / row / sequence       |
| `सम्भव<T>`          | `Option<T>`       | possible / potential          |
| `परिणाम<T, E>`      | `Result<T, E>`    | outcome / result              |
| `निघण्टु<K, V>`     | `HashMap<K, V>`   | glossary / lexicon (Vedic)    |
| `अनुक्रम<K, V>`     | `BTreeMap<K, V>`  | ordered sequence              |
| `वर्गः<T>`          | `HashSet<T>`      | class / group / set           |
| `पिटक<T>`           | `Box<T>`          | basket / container            |
| `संयोग<T>`          | `Arc<T>`          | union / conjunction           |

---

## Constants & variants

### Boolean, ordering, math

| Constant         | Value                  | अर्थ                     |
|------------------|------------------------|--------------------------|
| `सत्य`           | `true`                 | true                     |
| `असत्य`          | `false`                | false                    |
| `कुछ(v)`         | `Some(v)`              | a value is present       |
| `रिक्त`          | `None`                 | no value                 |
| `ठीक(v)`         | `Ok(v)`                | success                  |
| `त्रुटि(e)`      | `Err(e)`               | error                    |
| `कम`             | `Ordering::Less`       | less than                |
| `बराबर`          | `Ordering::Equal`      | equal                    |
| `अधिक`           | `Ordering::Greater`    | greater than             |
| `पाई`            | `3.14159…` (π)         | pi                       |
| `प्रकृति`        | `2.71828…` (e)         | Euler's number           |
| `द्विमूल`        | `1.41421…` (√2)        | square root of 2         |
| `अनंत`           | `f64::INFINITY`        | infinity                 |
| `अपरिभाषित`      | `f64::NAN`             | not a number             |

### Sanskrit variant aliases

| Constant          | Value          | अर्थ                    |
|-------------------|----------------|-------------------------|
| `विद्यमान(v)`     | `Some(v)`      | existing / present      |
| `अविद्यमान`      | `None`         | non-existing / absent   |
| `सिद्ध(v)`        | `Ok(v)`        | accomplished / proven   |
| `दोष(e)`          | `Err(e)`       | fault / defect          |

### Sanskrit number constants (`i32`)

| Constant       | Value     | Constant        | Value      |
|----------------|-----------|-----------------|------------|
| `नल`           | `0`       | `एकादश`         | `11`       |
| `एक`           | `1`       | `द्वादश`        | `12`       |
| `द्वि`         | `2`       | `विंशति`        | `20`       |
| `त्रि`         | `3`       | `पञ्चाशत्`      | `50`       |
| `चतुर`         | `4`       | `शत`            | `100`      |
| `पञ्च`         | `5`       | `सहस्र`         | `1,000`    |
| `षट`           | `6`       | `लक्ष`          | `1,00,000` |
| `सप्त`         | `7`       | `कोटि`          | `1,00,00,000` |
| `अष्ट`         | `8`       |                 |            |
| `नव`           | `9`       |                 |            |
| `दश`           | `10`      |                 |            |

`usize` variants: `नल_आ`, `एक_आ`, `द्वि_आ`, `त्रि_आ`, `दश_आ`, `शत_आ`, `सहस्र_आ`

---

## Macros

### Hindi macros

| Macro              | Rust equivalent    | विवरण                            |
|--------------------|--------------------|----------------------------------|
| `छापो!`            | `println!`         | Print line to stdout             |
| `छाप!`             | `print!`           | Print without newline            |
| `त्रुटि_छापो!`     | `eprintln!`        | Print line to stderr             |
| `स्वरूप!`          | `format!`          | Format into a `String`           |
| `लिखो!`            | `write!`           | Write formatted text to a writer |
| `पंक्तिलिखो!`      | `writeln!`         | Write line to a writer           |
| `जाँचो!`           | `dbg!`             | Debug-print with file and line   |
| `सूची_बनाओ!`       | `vec!`             | Create a `Vec`                   |
| `घबराओ!`           | `panic!`           | Panic with a message             |
| `दावा!`            | `assert!`          | Assert a condition               |
| `समता_दावा!`       | `assert_eq!`       | Assert equality                  |
| `असमता_दावा!`      | `assert_ne!`       | Assert inequality                |
| `करनाहै!`          | `todo!`            | Mark as not yet implemented      |
| `अपूर्ण!`          | `unimplemented!`   | Mark as unimplemented            |
| `अगम्य!`           | `unreachable!`     | Mark as unreachable              |
| `संयोग!`           | `concat!`          | Concatenate literals             |
| `पाठसंलग्न!`       | `include_str!`     | Include file as `&str`           |
| `बाइट_संलग्न!`     | `include_bytes!`   | Include file as `&[u8]`          |
| `पर्यावरण!`        | `env!`             | Read env var at compile time     |
| `विन्यास!`         | `cfg!`             | Evaluate cfg condition           |
| `नाम_पाठ!`         | `stringify!`       | Stringify tokens                 |

### Sanskrit macros

| Macro                 | Rust equivalent    | अर्थ                        |
|-----------------------|--------------------|------------------------------|
| `वद!`                 | `println!`         | speak / say                  |
| `उच्चार!`             | `print!`           | pronounce / utter            |
| `दोषवद!`              | `eprintln!`        | speak error                  |
| `रचय!`                | `format!`          | compose / create             |
| `श्रेणी_रचय!`         | `vec!`             | create a series              |
| `भय!`                 | `panic!`           | fear / alarm                 |
| `निश्चय!`             | `assert!`          | certainty / determination    |
| `समत्व_निश्चय!`       | `assert_eq!`       | equality certainty           |
| `विषमत्व_निश्चय!`    | `assert_ne!`       | inequality certainty         |
| `परीक्षण!`            | `dbg!`             | examination / testing        |
| `कर्तव्य!`            | `todo!`            | duty / what must be done     |
| `असाधित!`             | `unimplemented!`   | not yet accomplished         |
| `अगम्य_पथ!`          | `unreachable!`     | unreachable path             |

---

## Extension traits

All activated by `use devnagari::prelude::*`.

### `Vec<T>` and `[T]`

| Method              | Rust equivalent  | विवरण                         |
|---------------------|------------------|-------------------------------|
| `.लम्बाई()`         | `.len()`         | number of elements            |
| `.रिक्त_है()`       | `.is_empty()`    | true if empty                 |
| `.प्रथम()`          | `.first()`       | first element (`Option<&T>`)  |
| `.अंतिम()`          | `.last()`        | last element (`Option<&T>`)   |
| `.समाविष्ट(x)`      | `.contains(x)`   | true if `x` is present        |

### `String` and `str`

| Method                | Rust equivalent          | विवरण                       |
|-----------------------|--------------------------|-----------------------------|
| `.लम्बाई()`           | `.len()`                 | byte length                 |
| `.रिक्त_है()`         | `.is_empty()`            | true if empty               |
| `.अक्षर_संख्या()`    | `.chars().count()`       | number of Unicode characters|
| `.बड़ेअक्षर()`        | `.to_uppercase()`        | convert to uppercase        |
| `.छोटेअक्षर()`        | `.to_lowercase()`        | convert to lowercase        |
| `.छाँटो()`            | `.trim()`                | trim whitespace             |
| `.समाविष्ट(pat)`      | `.contains(pat)`         | substring check             |
| `.से_शुरू(pat)`       | `.starts_with(pat)`      | prefix check                |
| `.पर_समाप्त(pat)`     | `.ends_with(pat)`        | suffix check                |
| `.बदलो(from, to)`     | `.replace(from, to)`     | replace substring           |
| `.विभाजित(pat)`       | `.split(pat).collect()`  | split into `Vec<&str>`      |

### `Iterator`

| Method                 | Rust equivalent     | विवरण                             |
|------------------------|---------------------|------------------------------------|
| `.गणना()`              | `.count()`          | count elements                     |
| `.संग्रह()`            | `.collect()`        | collect into a collection          |
| `.योग()`               | `.sum()`            | sum all elements                   |
| `.गुणनफल()`            | `.product()`        | product of all elements            |
| `.अधिकतम()`            | `.max()`            | maximum element                    |
| `.न्यूनतम()`           | `.min()`            | minimum element                    |
| `.कोई(f)`              | `.any(f)`           | true if any element matches        |
| `.सभी(f)`              | `.all(f)`           | true if all elements match         |
| `.छानो(f)`             | `.filter(f)`        | keep elements matching predicate   |
| `.रूपांतर(f)`          | `.map(f)`           | transform each element             |
| `.समतलरूपांतर(f)`      | `.flat_map(f)`      | transform and flatten              |
| `.लो(n)`               | `.take(n)`          | take first `n` elements            |
| `.छोड़ो(n)`             | `.skip(n)`          | skip first `n` elements            |
| `.क्रमांकित()`         | `.enumerate()`      | pair with index                    |
| `.झाँकने_योग्य()`      | `.peekable()`       | make peekable                      |
| `.जोड़ो(other)`         | `.zip(other)`       | zip two iterators                  |
| `.जोड़_दो(other)`       | `.chain(other)`     | chain two iterators                |
| `.खोजो(f)`             | `.find(f)`          | first matching element             |
| `.स्थान(f)`            | `.position(f)`      | index of first match               |
| `.संकुचन(init, f)`     | `.fold(init, f)`    | reduce with accumulator            |
| `.प्रत्येक_हेतु(f)`    | `.for_each(f)`      | run closure on each element        |
| `.उलटो()`              | `.rev()`            | reverse (requires `DoubleEndedIterator`) |

### `Option<T>`

| Method         | Rust equivalent    | विवरण                          |
|----------------|--------------------|--------------------------------|
| `.कुछ_है()`    | `.is_some()`       | true if a value is present     |
| `.रिक्त_है()`  | `.is_none()`       | true if empty                  |
| `.खोलो()`      | `.unwrap()`        | extract value or panic         |
| `.या(default)` | `.unwrap_or(d)`    | extract or return default      |
| `.रूपांतर(f)`  | `.map(f)`          | transform the inner value      |

### `Result<T, E>`

| Method          | Rust equivalent    | विवरण                         |
|-----------------|--------------------|-------------------------------|
| `.ठीक_है()`     | `.is_ok()`         | true if success               |
| `.त्रुटि_है()`  | `.is_err()`        | true if error                 |
| `.खोलो()`       | `.unwrap()`        | extract value or panic        |
| `.या(default)`  | `.unwrap_or(d)`    | extract or return default     |
| `.रूपांतर(f)`   | `.map(f)`          | transform the `Ok` value      |

---

## Examples

### Hindi — struct, impl, match

```rust
use devnagari::prelude::*;

देव! {
    संरचना विद्यार्थी {
        नाम: पाठ,
        अंक: पूर्णांक,
    }

    क्रियान्वयन विद्यार्थी {
        कार्य नया(नाम: पाठ, अंक: पूर्णांक) -> स्वप्रकार {
            स्वप्रकार { नाम, अंक }
        }

        कार्य श्रेणी(&स्व) -> &str {
            मिलान स्व.अंक {
                90..=100 => "उत्कृष्ट",
                75..=89  => "अच्छा",
                50..=74  => "सामान्य",
                _        => "अनुत्तीर्ण",
            }
        }
    }
}

fn main() {
    मान छात्र = विद्यार्थी::नया("अर्जुन".to_string(), 88);
    छापो!("{} की श्रेणी: {}", छात्र.नाम, छात्र.श्रेणी());
    // अर्जुन की श्रेणी: अच्छा
}
```

### Hindi — enum, for loop, iterator extensions

```rust
use devnagari::prelude::*;

देव! {
    गणना दिन {
        सोमवार, मंगलवार, बुधवार, गुरुवार, शुक्रवार, शनिवार, रविवार,
    }

    कार्य सप्ताहांत_है(द: &दिन) -> bool {
        मिलान द {
            दिन::शनिवार | दिन::रविवार => सत्य,
            _ => असत्य,
        }
    }
}

fn main() {
    मान संख्याएँ = सूची_बनाओ![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    मान सम: सूची<पूर्णांक> = संख्याएँ.iter()
        .copied()
        .छानो(|&x| x % 2 == 0)
        .संग्रह();
    छापो!("सम संख्याएँ: {:?}", सम);
    // सम संख्याएँ: [2, 4, 6, 8, 10]

    मान योग: पूर्णांक = सम.iter().copied().योग();
    छापो!("योगफल: {}", योग);
    // योगफल: 30
}
```

### Sanskrit — struct, trait, impl

```rust
use devnagari::prelude::*;

देव! {
    लक्षण क्षेत्रफल {
        कर्म क्षेत्रफल(&आत्म) -> राशि;
    }

    रचना वृत्त { त्रिज्या: राशि }
    रचना आयत  { लम्बाई: राशि, चौड़ाई: राशि }

    साधन क्षेत्रफल कृते वृत्त {
        कर्म क्षेत्रफल(&आत्म) -> राशि {
            पाई * आत्म.त्रिज्या * आत्म.त्रिज्या
        }
    }

    साधन क्षेत्रफल कृते आयत {
        कर्म क्षेत्रफल(&आत्म) -> राशि {
            आत्म.लम्बाई * आत्म.चौड़ाई
        }
    }
}

fn main() {
    नियत व = वृत्त { त्रिज्या: पञ्च as f64 };
    नियत आ = आयत { लम्बाई: दश as f64, चौड़ाई: चतुर as f64 };

    वद!("वृत्त का क्षेत्रफल  = {:.2}", व.क्षेत्रफल());
    वद!("आयत का क्षेत्रफल = {:.2}", आ.क्षेत्रफल());
}
```

### Sanskrit — number constants, Option, Result

```rust
use devnagari::prelude::*;

fn main() {
    // Sanskrit numbers
    नियत परिणाम: अङ्क = एक + द्वि + त्रि + चतुर + पञ्च;
    वद!("१+२+३+४+५ = {}", परिणाम);   // 15

    // Option with Sanskrit variants
    नियत मान: सम्भव<अङ्क> = विद्यमान(पञ्च * दश);
    वद!("मान: {}", मान.या(नल));       // 50

    // Result with Sanskrit variants
    नियत फल: परिणाम<अङ्क, &str> = सिद्ध(शत);
    निश्चय!(फल.ठीक_है());

    // Math constants
    वद!("π  = {:.6}", पाई);
    वद!("e  = {:.6}", प्रकृति);
    वद!("√2 = {:.6}", द्विमूल);
}
```

### Async (with Tokio)

```rust
use devnagari::prelude::*;

देव! {
    अतुल्य कार्य डेटा_लाओ(url: &str) -> फल<पाठ, Box<गतिशील std::error::Error>> {
        मान प्रतिक्रिया = reqwest::get(url).प्रतीक्षा?;
        मान सामग्री = प्रतिक्रिया.text().प्रतीक्षा?;
        ठीक(सामग्री)
    }
}
```

---

## Module structure

```
devnagari
├── prelude          — re-exports everything; use devnagari::prelude::*
├── types            — Hindi type aliases (पूर्णांक, पाठ, सूची, …)
├── sanskrit         — Sanskrit type aliases, number constants, variant aliases
├── constants        — boolean, ordering, math constants (पाई, अनंत, …)
├── macros           — Hindi + Sanskrit macro aliases
└── traits           — extension traits for Vec, str, String, Iterator, Option, Result
```

The companion crate `devnagari_macros` provides the `देव!`, `dev!`, `#[देव_attr]`, and `#[dev_attr]` proc-macros. It is published separately but pulled in automatically as a dependency.

---

## Notes

- **Mixing Hindi and Sanskrit** — both keyword sets work inside the same `देव! { }` block. There is no conflict.
- **Your own names** — identifiers that are not in the keyword map (`अर्जुन`, `क्षेत्रफल`, `विद्यार्थी`, etc.) pass through untouched.
- **Regular Rust outside `देव!`** — you can mix regular Rust and Devanagari blocks freely in the same file.
- **`await`** — write `.प्रतीक्षा` (Hindi) or `.प्रतीक्षण` (Sanskrit) in place of `.await`.
- **`impl Trait for Type`** — use `कृते` (Sanskrit) or `प्रत्येक` (Hindi) for the `for` keyword in this context.
- **ASCII fallback** — if your editor or terminal cannot render Devanagari macro names, use `dev! { }` and `#[dev_attr]` instead.

---

## License

MIT — see [LICENSE](LICENSE).