GithubHelp home page GithubHelp logo

luigimassa / rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exercism/rust

0.0 0.0 0.0 3.51 MB

Exercism exercises in Rust.

Home Page: https://exercism.org/tracks/rust

License: MIT License

Shell 2.81% Python 0.21% Rust 96.98%

rust's Introduction

Exercism Rust Track

CI Join the chat at https://gitter.im/exercism/rust

Exercism exercises in Rust

Contributing

Check out our contributor documentation.

Exercise Tests

At the most basic level, Exercism is all about the tests. You can read more about how we think about test suites in the Exercism documentation.

Test files should use the following format:

extern crate exercise_name;

use exercise_name::*;

#[test]
fn test_descriptive_name() {
    assert_eq!(exercise_function(1), 1);
}

#[test]
#[ignore]
fn test_second_and_past_tests_ignored() {
    assert_ne!(exercise_function(1), 2);
}

Opening an Issue

If you plan to make significant or breaking changes, please open an issue so we can discuss it first. If this is a discussion that is relevant to more than just the Rust track, please open an issue in exercism/discussions.

Submitting a Pull Request

Pull requests should be focused on a single exercise, issue, or conceptually cohesive change. Please refer to Exercism's pull request guidelines.

Please follow the coding standards for Rust. rustfmt may help with this and can be installed with cargo install rustfmt.

Verifying your Change

Before submitting your pull request, you'll want to verify the changes in two ways:

  • Run all the tests for the Rust exercises
  • Run an Exercism-specific linter to verify the track

All the tests for Rust exercises can be run from the top level of the repo with _test/check_exercises.sh. If you are on a Windows machine, there are additional Windows-specific instructions for running this.

On modifying the exercises' README

Please note that the README of every exercise is formed using several templates, not all of which are necessarily present on this repo. The most important of these:

If you are modifying the section of the README that belongs to the template not from this repository, please consider opening a PR on the problem-specifications repository first.

Contributing a New Exercise

Please see the documentation about adding new exercises.

Note that:

  • The simplest way to generate, update or configure an exercise is to use the exercise utility provided in this repository. To compile the utility you can use the bin/build_exercise_crate.sh script or, if the script does not work for you, use the cargo build --release command in the util/exercise/ directory and then copy the exercise binary from the util/exercise/target/release/ directory into the bin/ directory. Use bin/exercise --help to learn about the existing commands and their possible usage.

  • Each exercise must stand on its own. Do not reference files outside the exercise directory. They will not be included when the user fetches the exercise.

  • Exercises must conform to the Exercism-wide standards described in the documentation.

  • Each exercise should have:

    exercises/exercise-name/
                            tests/exercise-name.rs  <- a test suite
                            src/lib.rs              <- an empty file or with exercise stubs
                            example.rs              <- example solution that satisfies tests
                            Cargo.toml              <- with version equal to exercise definition
                            Cargo.lock              <- Auto generated
                            README.md               <- Instructions for the exercise (see notes below)
    
  • The stub file and test suite should use only the Rust core libraries. Cargo.toml should not list any external dependencies as we don't want to make the student assume required crates. If an example.rs uses external crates, include Cargo-example.toml so that _tests/check_exercises.sh can compile with these when testing.

  • Except in extraordinary circumstances, the stub file should compile under cargo test --no-run. This allows us to check that the signatures in the stub file match the signatures expected by the tests. Use unimplemented!() as the body of each function to achieve this. If there is a justified reason why this is not possible, instead include a .custom."allowed-to-not-compile" key in the exercise's .meta/config.json containing the reason.

  • If porting an existing exercise from problem-specifications that has a canonical-data.json file, use the version in canonical-data.json for that exercise as your Cargo.toml version. Otherwise, use "0.0.0".

  • An exercise may contain .meta/hints.md. This is optional and will appear after the normal exercise instructions if present. Rust is different in many ways from other languages. This is a place where the differences required for Rust are explained. If it is a large change, you may want to call this out as a comment at the top of src/lib.rs, so the user recognizes to read this section before starting.

  • If the test suite is appreciably sped up by running in release mode, and there is reason to be confident that the test suite appropriately detects any overflow errors, consider adding a marker to the exercise's .meta/config.json: .custom."test-in-release-mode" should be true. This can particularly impact the online editor experience.

  • If your exercise implements macro-based testing (see #392 and perfect-numbers.rs), you will likely run afoul of a CI check which counts the #[ignore] lines and compares the result to the number of #[test] lines. To fix this, add a marker to the exercise's .meta/config.json: .custom."ignore-count-ignores" should be true to disable that check for your exercise.

  • README.md may be regenerated from Exercism data. The generator will use the description.md from the exercise directory in the problem-specifications repository, then any hints in .meta/hints.md, then the Rust-specific instructions. The ## Source section comes from the metadata.yml in the same directory. Convention is that the description of the source remains text and the link is both name and hyperlink of the markdown link.

  • Be sure to add the exercise to an appropriate place in the config.json file. The position in the file determines the order exercises are sent. Generate a unique UUID for the exercise. Current difficulty levels in use are 1, 4, 7 and 10.

rust's People

Contributors

andrewclarkson avatar bobahop avatar ccouzens avatar clashthebunny avatar coriolinus avatar cwhakes avatar cypher avatar dependabot[bot] avatar eduardobautista avatar efx avatar emerentius avatar erikschierboom avatar etrepum avatar exercism-bot avatar ianwhitney avatar ihid avatar kytrinyx avatar lewisclement avatar myucesan avatar navossoc avatar ocstl avatar pault89 avatar pedantic79 avatar petertseng avatar pminten avatar razielgn avatar sacherjj avatar stevejb71 avatar workingjubilee avatar zapanton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.