How to Contribute to a Open-Source Rust Project as Beginner
Tags: rust, beginners, programming, opensource
Published: 2022-07-24 09:14:00

Rust has become a popular programming language and, according to Stack Overflow, has been the most loved language for consecutive years.

I will not repeat myself. For mastering RUST, a lot of hands-on is needed, check my previous [article](https://dev.to/nathan20/learning-rust-a-way-of-thinking-fbi) for more information.
Open source is a great way for beginners to get involved in coding and development. By contributing to open source projects, beginners can learn from more experienced developers and gain valuable experience. Open source also provides a great way for beginners to collaborate with others and build something that is useful for the community.
This article will help you to understand how to contribute to an open-source project from the beginning.



## First Contributions
Firstly you need to chose a RUST project according to your level.
Please ensure that you have git installed on your machine, 
If you don't have please follow this [article](https://docs.github.com/en/get-started/quickstart/set-up-git).
Then note that you are going to need RUST installed on your computer.

## Fork

Fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.
Go the main page's of the open source project and check the "Contribute.md" this file give  you all you need to know  for contributing, generally also indicates which branch is dedicate for contributing.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gley5st964n2g7lcz801.png)

## Clone the repository
We are going to work locally on the project, so we need to clone the forked repository.
Clone is used to create a copy of a git repository. Clone creates a local copy of the remote repository.
`git clone https://github.com/YOUR_USERNAME/project_name.git`

## Create your own branch
There are a few reasons why you might want to develop on a separate branch:

1. It allows you to keep your development work separate from your main branch (usually "master"). This is helpful if you want to experiment with new features or ideas without affecting the stability of your main branch.

2. It allows you to share your work-in-progress with others without having to merge it into the main branch. This can be helpful for collaboration or feedback.

3. It allows you to easily "revert" your changes if you decide that they're not good after all. This can save you a lot of time and hassle compared to trying to fix things on your main branch.

Go to the cloned repository:
`cd project_name`
 
Create a  new branch.
`git switch -c your-new-branch-name`

## Let's contribute and make your own change

Please read carefully the Contribute.MD and check what the company's needs are.
Let's take as example [CherryBomb](https://github.com/blst-security/cherrybomb) (Rust open source API security project).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sswvlmyxvjriwa4qo6bu.png)

I wrote a simple  function that checks an element from the [OAS](https://swagger.io/specification/#oas-version)(open api specification) file.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5agm8lzgysvuruwbua1.png)
Add the function to the check.rs file.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ct12riu5vxfvwh73w2ds.png)
In all only two files has been changed.
 
Now add those changed to your branch.
`git commit add -A`
Now commit those changed.
`git commit -m " my first contribution"`

## Push
 
For the moment, your changes are only locally saved. We are going to save them in the cloud, in our case,to forked repository.
`git push origin -u <add-your-branch-name>`


##Final step, Submit.

In order to finish your contribution you need to pull your code.
What is a pull request?
A pull request is a way to request that someone else (usually a project maintainer) pull changes from your branch into their branch. This is usually used when you have made changes that you want to contribute to a project, but are not ready to merge them into the main branch yet.

So go to your repository on GitHub, click on "Pull request" button on the top, then "new pull request".
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qihinfx8v907y5hyqe13.png)
Submit.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs5dfowvsah7u287zfhl.png)
 

Now the maintainer will audit and review your pull request. If there is no need to modify something, your code will be merged into the master branch, and you will get a notification email.

##What is the next step? 

If you liked to read this article don't hesitate to give us a star at our GitHub [repo](https://github.com/blst-security/cherrybomb).
Stay tuned. In my next article I will give you a list of beginner open-source repos to contribute to.

Between this, you can contribute to [CherryBomb](https://github.com/blst-security/cherrybomb/blob/active-method_permissions/CONTRIBUTING.md).

If you have any idea, or questions let's talk  at our Discord Server: [https://discord.gg/Krd4sNkk](https://discord.gg/Krd4sNkk).