Skip to content

A lightweight tool converting select Python constructs to Rust, aiding developers in understanding transpilation basics.

License

Notifications You must be signed in to change notification settings

urso-ai/rusthon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Version

rusthon is a minimalist transpilation tool that converts a subset of the Python language to Rust. Designed to help developers grasp the basic concepts of transpilation, Rusthon provides a direct translation of common Python constructs to their Rust counterparts.

Feature

Currently, Rusthon supports the transpilation of the following constructs:

  • Functions with typed arguments and a typed return.
  • Basic arithmetic operations (+, -, *, /).
  • Function calls.
  • Variable assignments.
  • The conditional declaration if name == "main":.
  • The print() function.
  • For loop and range()
  • Class definitions
    • using types is better: def __init__(self, name: str, age: int)

How to Use

  1. Clone the repository:
git clone https://github.com/urso-ai/rusthon.git
cd rusthon
  1. Place your Python code in the test_sample.py file.
  2. Run main.py:
python main.py
  1. The resulting Rust code will be diplayed on the standard output.

Limitations

Rusthon is a teaching tool designed to transpile a specific subset of Python. As such, many Python language constructs, such as loops, classes, and exception handling, are not yet supported. Contributions to expand functionality are welcome!

Contributing

If you'd like to contribute to the project, feel free to fork and send a pull request. Any feedback or suggestions are appreciated!

License

MIT

About

A lightweight tool converting select Python constructs to Rust, aiding developers in understanding transpilation basics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages