Expand description
§देवनागरी — Code in Hindi/Sanskrit with Rust
This crate lets you write idiomatic Rust using Devanagari vocabulary:
- Type aliases —
पूर्णांक(i32),पाठ(String),सूची<T>(Vec<T>), … - Macro aliases —
छापो!(println!),स्वरूप!(format!),घबराओ!(panic!), … - Extension traits —
.लम्बाई(),.रिक्त_है(),.खोलो(), … देव! { }proc-macro — translates Devanagari keywords to Rust keywords
§Quick start
use devnagari::prelude::*;
देव! {
कार्य अभिवादन(नाम: &str) -> पाठ {
स्वरूप!("नमस्ते, {}!", नाम)
}
}
fn main() {
let greeting = अभिवादन("विश्व");
छापो!("{}", greeting);
}§Keyword map (inside देव! { })
| Devanagari | Rust |
|---|---|
कार्य | fn |
मान | let |
परिवर्तनीय | mut |
यदि | if |
अन्यथा | else |
जबतक | while |
प्रत्येक | for |
चक्र | loop |
मिलान | match |
वापस | return |
संरचना | struct |
गणना | enum |
विशेषता | trait |
क्रियान्वयन | impl |
सार्वजनिक | pub |
स्थिरांक | const |
सत्य / असत्य | true / false |
Modules§
Macros§
- dev
- ASCII alias for
देव!— use when your editor doesn’t support Devanagari macro names. - अगम्य
unreachable!— mark unreachable code paths अगम्य → “unreachable”- अगम्य_
पथ unreachable!— अगम्य_पथ = “unreachable path”- अपूर्ण
unimplemented!— mark not-yet-implemented code अपूर्ण → “incomplete”- असमता_
दावा assert_ne!— inequality assertion असमता_दावा → “inequality assertion”- असाधित
unimplemented!— असाधित = “not yet accomplished”- उच्चार
print!— उच्चार = “pronounce / utter”- करनाहै
todo!— mark unimplemented code करनाहै → “needs to be done”- कर्तव्य
todo!— कर्तव्य = “duty / what must be done”- घबराओ
panic!— cause a panic घबराओ → “panic / be alarmed”- छाप
print!— print without newline छाप → “print”- छापो
println!— print a line to stdout छापो → “print it”- जाँचो
dbg!— debug print a value जाँचो → “inspect / check”- त्रुटि_
छापो eprintln!— print a line to stderr त्रुटि_छापो → “print error”- दावा
assert!— assertion दावा → “assertion / claim”- देव
देव!— Devanagari keyword translation macro- दोषवद
eprintln!— दोषवद = “speak error”- नाम_
पाठ stringify!— turn tokens into a string literal at compile time नाम_पाठ → “name as text”- निश्चय
assert!— निश्चय = “certainty / determination”- पंक्तिलिखो
writeln!— write formatted text with newline to a writer पंक्तिलिखो → “write line”- परीक्षण
dbg!— परीक्षण = “examination / testing”- पर्यावरण
env!— read an environment variable at compile time पर्यावरण → “environment”- पाठसंलग्न
include_str!— include a file as a string at compile time पाठसंलग्न → “include text”- बाइट_
संलग्न include_bytes!— include a file as a byte array at compile time बाइट_संलग्न → “include bytes”- भय
panic!— भय = “fear / alarm” (Sanskrit)- रचय
format!— रचय = “compose / create” (Sanskrit imperative)- लिखो
write!— write formatted text to a writer लिखो → “write”- वद
println!— वद = “speak / say” (Sanskrit imperative)- विन्यास
cfg!— evaluate a cfg condition at runtime (returns bool) विन्यास → “configuration”- विषमत्व_
निश्चय assert_ne!— विषमत्व_निश्चय = “inequality certainty”- श्रेणी_
रचय vec!— श्रेणी_रचय = “create a series”- संयोग
concat!— concatenate literals at compile time संयोग → “concatenation / union”- समता_
दावा assert_eq!— equality assertion समता_दावा → “equality assertion”- समत्व_
निश्चय assert_eq!— समत्व_निश्चय = “equality certainty”- सूची_
बनाओ vec!— create a Vec सूची → “list”- स्वरूप
format!— format a string स्वरूप → “form / format”