5: Add Rust track exercise "Gigasecond".

[?]
Aaw9nJhsNmfzFih9mKyNw9mV8CgERXJkRa1kK1Kx3LQH
Oct 10, 2021, 2:15 PM
JEYE3DLSV5TJ3RL2ZMQRE7JIOWIVP2JZA7DKPEOYPL44SWFYXOLQC

Dependencies

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

Change contents

  • file addition: gigasecond (d--r------)
    [2.16]
  • file addition: tests (d--r------)
    [0.22]
  • file addition: gigasecond.rs (----------)
    [0.40]
    use chrono::{TimeZone, Utc};
    #[test]
    fn test_date() {
    let start_date = Utc.ymd(2011, 4, 25).and_hms(0, 0, 0);
    assert_eq!(
    gigasecond::after(start_date),
    Utc.ymd(2043, 1, 1).and_hms(1, 46, 40)
    );
    }
    #[test]
    #[ignore]
    fn test_another_date() {
    let start_date = Utc.ymd(1977, 6, 13).and_hms(0, 0, 0);
    assert_eq!(
    gigasecond::after(start_date),
    Utc.ymd(2009, 2, 19).and_hms(1, 46, 40)
    );
    }
    #[test]
    #[ignore]
    fn test_third_date() {
    let start_date = Utc.ymd(1959, 7, 19).and_hms(0, 0, 0);
    assert_eq!(
    gigasecond::after(start_date),
    Utc.ymd(1991, 3, 27).and_hms(1, 46, 40)
    );
    }
    #[test]
    #[ignore]
    fn test_datetime() {
    let start_date = Utc.ymd(2015, 1, 24).and_hms(22, 0, 0);
    assert_eq!(
    gigasecond::after(start_date),
    Utc.ymd(2046, 10, 2).and_hms(23, 46, 40)
    );
    }
    #[test]
    #[ignore]
    fn test_another_datetime() {
    let start_date = Utc.ymd(2015, 1, 24).and_hms(23, 59, 59);
    assert_eq!(
    gigasecond::after(start_date),
    Utc.ymd(2046, 10, 3).and_hms(1, 46, 39)
    );
    }
  • file addition: src (d--r------)
    [0.22]
  • file addition: lib.rs (----------)
    [0.1194]
    use chrono::{DateTime, Utc};
    // Returns a Utc DateTime one billion seconds after start.
    pub fn after(start: DateTime<Utc>) -> DateTime<Utc> {
    unimplemented!("What time is a gigasecond later than {}", start);
    }
  • file addition: README.md (----------)
    [0.22]
    # Gigasecond
    Welcome to Gigasecond on Exercism's Rust Track.
    If you need help running the tests or submitting your code, check out `HELP.md`.
    ## Instructions
    Given a moment, determine the moment that would be after a gigasecond
    has passed.
    A gigasecond is 10^9 (1,000,000,000) seconds.
    If you're unsure what operations you can perform on `DateTime<Utc>` take a look at the [chrono crate](https://docs.rs/chrono) which is listed as a dependency in the `Cargo.toml` file for this exercise.
    ## Source
    ### Created by
    - @IanWhitney
    ### Contributed to by
    - @andy5995
    - @ashleygwilliams
    - @cbzehner
    - @coriolinus
    - @cwhakes
    - @EduardoBautista
    - @efx
    - @ErikSchierboom
    - @houhoulis
    - @IanWhitney
    - @janczer
    - @leoyvens
    - @lutostag
    - @mkantor
    - @nfiles
    - @NieDzejkob
    - @ocstl
    - @petertseng
    - @rofrol
    - @sacherjj
    - @stringparser
    - @xakon
    - @ZapAnton
    ### Based on
    Chapter 9 in Chris Pine's online Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=09
  • file addition: HELP.md (----------)
    [0.22]
    # 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.22]
    [package]
    edition = "2018"
    name = "gigasecond"
    version = "2.0.0"
    [dependencies]
    chrono = "0.4"
  • file addition: .gitignore (----------)
    [0.22]
    # 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.22]
  • file addition: metadata.json (----------)
    [0.5765]
    {"track":"rust","exercise":"gigasecond","id":"d09ccefb019e4079969f6ea31439a1e8","url":"https://exercism.org/tracks/rust/exercises/gigasecond","handle":"nicoty","is_requester":true,"auto_approve":false}
  • file addition: config.json (----------)
    [0.5765]
    {
    "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.",
    "authors": [
    "IanWhitney"
    ],
    "contributors": [
    "andy5995",
    "ashleygwilliams",
    "cbzehner",
    "coriolinus",
    "cwhakes",
    "EduardoBautista",
    "efx",
    "ErikSchierboom",
    "houhoulis",
    "IanWhitney",
    "janczer",
    "leoyvens",
    "lutostag",
    "mkantor",
    "nfiles",
    "NieDzejkob",
    "ocstl",
    "petertseng",
    "rofrol",
    "sacherjj",
    "stringparser",
    "xakon",
    "ZapAnton"
    ],
    "files": {
    "solution": [
    "src/lib.rs"
    ],
    "test": [
    "tests/gigasecond.rs"
    ],
    "example": [
    ".meta/example.rs"
    ]
    },
    "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.",
    "source_url": "http://pine.fm/LearnToProgram/?Chapter=09"
    }