pub struct IR {
pub ir: String,
}Fields§
§ir: StringImplementations§
Source§impl IR
impl IR
Sourcepub fn new(ir: String) -> Self
pub fn new(ir: String) -> Self
Examples found in repository?
examples/usage.rs (line 22)
3fn main() {
4 let ir_json = r#"
5 {
6 "imports": ["sys", "os"],
7 "var:my_variable": {
8 "value": "hello world"
9 },
10 "var:count": {
11 "value": 42
12 },
13 "var:is_active": {
14 "value": true
15 },
16 "call:echo": {
17 "args": ["Hello", "@my_variable"]
18}
19 }
20 "#;
21
22 let ir = IR::new(ir_json.to_string());
23
24 for lang in ["Python", "JavaScript", "Lua"] {
25 println!("=== {} ===", lang);
26 match ir.transpile(lang) {
27 Ok(code) => println!("{}", code),
28 Err(e) => eprintln!("Ошибка: {}", e),
29 }
30 }
31}Sourcepub fn transpile(&self, lang: &str) -> Result<String, IRError>
pub fn transpile(&self, lang: &str) -> Result<String, IRError>
Examples found in repository?
examples/usage.rs (line 26)
3fn main() {
4 let ir_json = r#"
5 {
6 "imports": ["sys", "os"],
7 "var:my_variable": {
8 "value": "hello world"
9 },
10 "var:count": {
11 "value": 42
12 },
13 "var:is_active": {
14 "value": true
15 },
16 "call:echo": {
17 "args": ["Hello", "@my_variable"]
18}
19 }
20 "#;
21
22 let ir = IR::new(ir_json.to_string());
23
24 for lang in ["Python", "JavaScript", "Lua"] {
25 println!("=== {} ===", lang);
26 match ir.transpile(lang) {
27 Ok(code) => println!("{}", code),
28 Err(e) => eprintln!("Ошибка: {}", e),
29 }
30 }
31}Auto Trait Implementations§
impl Freeze for IR
impl RefUnwindSafe for IR
impl Send for IR
impl Sync for IR
impl Unpin for IR
impl UnsafeUnpin for IR
impl UnwindSafe for IR
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more