3: Add Rust track exercise "Reverse String".

[?]
Aaw9nJhsNmfzFih9mKyNw9mV8CgERXJkRa1kK1Kx3LQH
Oct 10, 2021, 2:04 PM
W2V5PYAQ6CH5ALKJCNZOT4T5DGBL3BAPVHXSRR7IJASPYTWWFHIAC

Dependencies

  • [2] OSLWPPDF 1: Add Rust track exercise "Hello World".

Change contents

  • file addition: reverse-string (d--r------)
    [2.16]
  • file addition: tests (d--r------)
    [0.26]
  • file addition: reverse-string.rs (----------)
    [0.44]
    //! Tests for reverse-string
    //!
    //! Generated by [script][script] using [canonical data][canonical-data]
    //!
    //! [script]: https://github.com/exercism/rust/blob/b829ce2/bin/init_exercise.py
    //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/reverse-string/canonical_data.json
    use reverse_string::*;
    /// Process a single test case for the property `reverse`
    fn process_reverse_case(input: &str, expected: &str) {
    assert_eq!(&reverse(input), expected)
    }
    #[test]
    /// empty string
    fn test_an_empty_string() {
    process_reverse_case("", "");
    }
    #[test]
    #[ignore]
    /// a word
    fn test_a_word() {
    process_reverse_case("robot", "tobor");
    }
    #[test]
    #[ignore]
    /// a capitalized word
    fn test_a_capitalized_word() {
    process_reverse_case("Ramen", "nemaR");
    }
    #[test]
    #[ignore]
    /// a sentence with punctuation
    fn test_a_sentence_with_punctuation() {
    process_reverse_case("I'm hungry!", "!yrgnuh m'I");
    }
    #[test]
    #[ignore]
    /// a palindrome
    fn test_a_palindrome() {
    process_reverse_case("racecar", "racecar");
    }
    #[test]
    #[ignore]
    /// an even-sized word
    fn test_an_even_sized_word() {
    process_reverse_case("drawer", "reward");
    }
    #[test]
    #[ignore]
    /// wide characters
    fn test_wide_characters() {
    process_reverse_case("子猫", "猫子");
    }
    #[test]
    #[ignore]
    #[cfg(feature = "grapheme")]
    /// grapheme clusters
    fn test_grapheme_clusters() {
    process_reverse_case("uüu", "uüu");
    }
  • file addition: src (d--r------)
    [0.26]
  • file addition: lib.rs (----------)
    [0.1561]
    pub fn reverse(input: &str) -> String {
    unimplemented!("Write a function to reverse {}", input);
    }
  • file addition: README.md (----------)
    [0.26]
    # Reverse String
    Welcome to Reverse String on Exercism's Rust Track.
    If you need help running the tests or submitting your code, check out `HELP.md`.
    ## Instructions
    Reverse a string
    For example:
    input: "cool"
    output: "looc"
    Test your function on this string: `uüu` and see what happens. Try to write a function that properly
    reverses this string. Hint: grapheme clusters
    To get the bonus test to run, remove the ignore flag (`#[ignore]`) from the
    last test, and execute the tests with:
    ```bash
    $ cargo test --features grapheme
    ```
    You will need to use external libraries (a `crate` in rust lingo) for the bonus task. A good place to look for those is [crates.io](https://crates.io/), the official repository of crates.
    [Check the documentation](https://doc.rust-lang.org/cargo/guide/dependencies.html) for instructions on how to use external crates in your projects.
    ## Source
    ### Created by
    - @coriolinus
    ### Contributed to by
    - @cbzehner
    - @ccouzens
    - @cwhakes
    - @efx
    - @ErikSchierboom
    - @hunger
    - @lutostag
    - @ocstl
    - @petertseng
    - @rofrol
    - @rrredface
    - @stringparser
    - @TheDarkula
    - @xakon
    - @ZapAnton
    ### Based on
    Introductory challenge to reverse an input string - https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb
  • file addition: HELP.md (----------)
    [0.26]
    # Help
    ## Running the tests
    Execute the tests with:
    ```bash
    $ cargo test
    ```
    All but the first test have been ignored. After you get the first test to
    pass, open the tests source file which is located in the `tests` directory
    and remove the `#[ignore]` flag from the next test and get the tests to pass
    again. Each separate test is a function with `#[test]` flag above it.
    Continue, until you pass every test.
    If you wish to run _only ignored_ tests without editing the tests source file, use:
    ```bash
    $ cargo test -- --ignored
    ```
    If you are using Rust 1.51 or later, you can run _all_ tests with
    ```bash
    $ cargo test -- --include-ignored
    ```
    To run a specific test, for example `some_test`, you can use:
    ```bash
    $ cargo test some_test
    ```
    If the specific test is ignored, use:
    ```bash
    $ cargo test some_test -- --ignored
    ```
    To learn more about Rust tests refer to the online [test documentation][rust-tests].
    [rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html
    ## Submitting your solution
    You can submit your solution using the `exercism submit src/lib.rs` command.
    This command will upload your solution to the Exercism website and print the solution page's URL.
    It's possible to submit an incomplete solution which allows you to:
    - See how others have completed the exercise
    - Request help from a mentor
    ## Need to get help?
    If you'd like help solving the exercise, check the following pages:
    - The [Rust track's documentation](https://exercism.org/docs/tracks/rust)
    - [Exercism's support channel on gitter](https://gitter.im/exercism/support)
    - The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
    Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
    ## Rust Installation
    Refer to the [exercism help page][help-page] for Rust installation and learning
    resources.
    ## Submitting the solution
    Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer.
    ## Feedback, Issues, Pull Requests
    The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
    If you want to know more about Exercism, take a look at the [contribution guide].
    ## Submitting Incomplete Solutions
    It's possible to submit an incomplete solution so you can see how others have completed the exercise.
    [help-page]: https://exercism.io/tracks/rust/learning
    [github]: https://github.com/exercism/rust
    [contribution guide]: https://exercism.io/docs/community/contributors
  • file addition: Cargo.toml (----------)
    [0.26]
    [dependencies]
    [features]
    grapheme = []
    [package]
    edition = "2018"
    name = "reverse_string"
    version = "1.2.0"
  • file addition: .gitignore (----------)
    [0.26]
    # Generated by Cargo
    # will have compiled files and executables
    /target/
    **/*.rs.bk
    # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
    # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
    Cargo.lock
  • file addition: .exercism (d--r------)
    [0.26]
  • file addition: metadata.json (----------)
    [0.6359]
    {"track":"rust","exercise":"reverse-string","id":"7ee05187587b4b43812448709a4019a3","url":"https://exercism.org/tracks/rust/exercises/reverse-string","handle":"nicoty","is_requester":true,"auto_approve":false}
  • file addition: config.json (----------)
    [0.6359]
    {
    "blurb": "Reverse a string",
    "authors": [
    "coriolinus"
    ],
    "contributors": [
    "cbzehner",
    "ccouzens",
    "cwhakes",
    "efx",
    "ErikSchierboom",
    "hunger",
    "lutostag",
    "ocstl",
    "petertseng",
    "rofrol",
    "rrredface",
    "stringparser",
    "TheDarkula",
    "xakon",
    "ZapAnton"
    ],
    "files": {
    "solution": [
    "src/lib.rs"
    ],
    "test": [
    "tests/reverse-string.rs"
    ],
    "example": [
    ".meta/example.rs"
    ]
    },
    "source": "Introductory challenge to reverse an input string",
    "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb"
    }