Java to Rust Converter


#1

Hello,
sorry, changing the title duplicates the post and I could not figure out, how to delete it. There is nothing new here:
Please look into java-to-rust-converter-for-tedious-editing-tasks

I am a former C++ now Java-Programmer, quite new in Rust and am fascinated about the safety features of this language. So I thought, why not try to port some functionality implemented in Java to Rust.
I started with the math3 artefact from apache.

There are some task which are always the same, therefore I wrote a small server which is capable of parsing Java-Code and creating “rust”-code.

Use:
java to rust converter

A short meaningless code-snippet

class A {
     public A() {
       int i = 10;
       double f = 1;
       for (int i = 10; i < 100; i++) {
         f += i;
       }
   }
}

becomes:
struct A {
}

impl A {

  pub fn new() -> A {
     let i: i32 = 10;
     let mut f: f64 = 1;
     {
        let mut i: i32 = 10;
        while i < 100 {
            {
                f += i;
            }
            i += 1;
         }
     }
}

}


#2

how it worked?


#3

First:
Please look into java-to-rust-converter-for-tedious-editing-tasks for more information.
I accidentally duplicated the post by changing the title.

Second:
I do not understand correctly, did you try to paste some java-code into: converter, and pressed Convert?

The result you can see and copy from the editfield on the right.

The server/program works by using the javaparser-module on github and letting work some Iterators on top on the syntax tree.