A repository for completing this issue on mozilla/rust. This repository contains minimal working code for many simple (and not so simple) tasks. New contributors and learners of the language are welcome. We will try to work with you to make the code more idiomatic over time.
Working on a problem, need some help? Drop by #rust-rosetta on irc.mozilla.org. Get in touch with @Hoverbear if you need help setting up.
Looking to help out? Great, thanks! We have a few guidelines:
- The code you contribute is public domain.
- Your code should build cleanly on the
master
branch of Rust. - Keep your code as simple as possible, please avoid Dead Code warnings.
- Don't be afraid of comments, the code is going to be written once, read hundreds of times, and maintained until past the 1.0 release of Rust.
- Include a link to the Rosetta Code Problem at the top of the code sample.
- Add a line to the Readme section below. (It's alphabetical!)
- Unit tests are strongly encouraged. Having troubles getting the build to work? Check about Not Test Flags
If you have unit-tests, you will need to mark fn main
, and possibly
some other fn
s with #[cfg(not(test))]
to avoid dead-code warnings.
The reason dead-code warnings appear is because main
is never called
during a test.
#[cfg(not(test))]
fn main() {
println!("I need to be not compiled during tests");
}
#[test]
fn test_me() {
assert!(true);
}
If you are unable to test your program then mark the entire file with
// not_tested
. This will disable testing completely for that
file.
// not_tested
fn main(){
println!("Please add unit-tests later.");
}
The top of your code should look like this:
// http://rosettacode.org/wiki/foo
If you'd like, you're welcome to add your contact details, name, or other information as well.
If you look here you can see how most contributions "merge" over time with the main tree. People will create multiple branches off the same main repo. So you see your long one? Instead of multiple branches coming and going off the main repo, it's one long one.
Here's an idea of what a workflow would look like (in general-ish):
If it's your first time
- Choose a problem off Rosetta Code.
- Fork this repo on Github. (Help here!)
- Clone your resulting repo onto your machine.
Every other time
- Navigate to your
rust-rosetta
directory. - Make sure you're on
master
branch. - Update your fork (Details)
- Create a branch that is reasonably unique
Ein06-func-impl
is a good example. - Make your changes for this problem.
- Add the new definition to the README.md
- Add one code file with the appropriate name to the
src/
directory. If you need any data there is a separate folder for that. - Make sure to include unit tests for us, and comments! :)
- Check
git status
to make sure you don't mangle anything else. - Commit your changes (
git commit -a -m "Implement blah blah blah"
) - Submit a Pull request here.
After it's accepted
- Delete the branch.
If this is unclear or you're having difficulties, just open an issue, we'd love to help.