Hacker News new | ask | show | jobs
by aardshark 996 days ago
Open up Chat GPT, paste your functions and ask it to convert them to rust. Go through them 1 by 1, see if you understand and ask questions about anything you don't recognise. Don't expect the output to be perfectly logically correct, you will have to ensure that yourself.

I've found Chat GPT to be really excellent for quickly getting myself up to speed with languages that I'm not familiar with.

1 comments

Yes, that’s my advice as well. Set up vscode with rust analyzer and paste any errors it shows back into the same ChatGPT conversation and it will debug everything for you.
Thanks, that sounds good.

I will search myself, but is there are a great rust syntax reference doc?

The syntax isn’t really the hard part, it’s the rules around memory ownership and when you need to clone variables. There are lots of gotchas and the compiler is very unforgiving. If you want to convert your 5 functions into rust in a reasonable time instead of spending weeks grappling with the differences, just use ChatGPT and iterate by pasting in the errors from rust analyzer and the compiler.

If you actually want to learn rust then that’s a different story and you should probably check out Steve Klabnik‘s book or something like that (or just look at the sample code I linked to in my other comment from my own recent rust library for python).