Giter VIP home page Giter VIP logo

build-your-own-jira-with-rust's Issues

Swp files cause the current koan to be repeated

If there is a .01_ticket.rs.swp file then this gets added to the list of koans as a second instance of the current koan. This means that when tests pass it asks if you'd like to move onto the next koan but repeats the current one instead.

error[E0428]: the name `greetings` is defined multiple times
 --> jira-wip/src/path_to_enlightenment.rs:6:1
  |
3 | mod greetings;
  | -------------- previous definition of the module `greetings` here
...
6 | mod greetings;
  | ^^^^^^^^^^^^^^ `greetings` redefined here
  |
  = note: `greetings` must be defined only once in the type namespace of this module

For more information about this error, try `rustc --explain E0428`.
error: could not compile `jira-wip` (bin "jira-wip" test) due to previous error

(01) ticket - (03) validation

            // You should be seeing this error when trying to run this koan:
            //
            // error[E0616]: field `description` of struct `path_to_enlightenment::visibility::ticket::Ticket` is private
            // --> jira-wip/src/koans/01_ticket/04_visibility.rs:99:25
            //    |
            // 99 |              assert_eq!(ticket.description, "A description");
            //    |                         ^^^^^^^^^^^^^^^^^^
            //
            // If that is the case, comment the next line out and move on to the next koan!
            assert_eq!(ticket.description, "A description");

The above is all true, but I see this error without having Add the necessary pub modifiers in the code above... i.e. I made no modifications and it's instructing me to go to the next koan?

Also maybe be a bit more explicit on this step:
Once you have verified that it does not compile, =>
Once you have verified that the below does not compile,

(02) ticket_store - (08) delete_and_update test failed

> koans --path jira-wip/


Running tests...

        ๐Ÿš€ (00) greetings - (00) greetings
        ๐Ÿš€ (01) ticket - (01) ticket
        ๐Ÿš€ (01) ticket - (02) status
        ๐Ÿš€ (01) ticket - (03) validation
        ๐Ÿš€ (01) ticket - (04) visibility
        ๐Ÿš€ (01) ticket - (05) ownership
        ๐Ÿš€ (01) ticket - (06) traits
        ๐Ÿš€ (01) ticket - (07) derive
        ๐Ÿš€ (01) ticket - (08) recap
        ๐Ÿš€ (02) ticket_store - (01) store
        ๐Ÿš€ (02) ticket_store - (02) option
        ๐Ÿš€ (02) ticket_store - (03) id_generation
        ๐Ÿš€ (02) ticket_store - (04) metadata
        ๐Ÿš€ (02) ticket_store - (05) type_as_constraints
        ๐Ÿš€ (02) ticket_store - (06) result
        ๐Ÿš€ (02) ticket_store - (07) vec
        โŒ (02) ticket_store - (08) delete_and_update

        Meditate on your approach and return. Mountains are merely mountains.




running 15 tests
............F..
failures:

---- path_to_enlightenment::delete_and_update::tests::update_works stdout ----
thread 'path_to_enlightenment::delete_and_update::tests::update_works' panicked at 'assertion failed: `(left != right)`
  left: `2020-04-16T15:28:58.708731250Z`,
 right: `2020-04-16T15:28:58.708731250Z`', jira-wip/src/koans/02_ticket_store/08_delete_and_update.rs:272:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    path_to_enlightenment::delete_and_update::tests::update_works

test result: FAILED. 14 passed; 1 failed; 0 ignored; 0 measured; 41 filtered out

warning: unused imports: `Status`, `Ticket`, `create_ticket`
  --> jira-wip/src/koans/01_ticket/04_visibility.rs:62:29
   |
62 |         use super::ticket::{create_ticket, Status, Ticket};
   |                             ^^^^^^^^^^^^^  ^^^^^^  ^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error: test failed, to rerun pass '--bin jira-wip'

Code

        /// If the `id` passed in matches a ticket in the store, we return the deleted ticket
        /// with some additional metadata.
        /// If it doesn't, we return `None`.
        pub fn delete(&mut self, id: &TicketId) -> Option<DeletedTicket> {
            self.data.remove(id).and_then(|ticket| Some(DeletedTicket {
                ticket,
                deleted_at: Utc::now(),
            }))
        }

I think that is the same code as 09 but the code does not work.

Koan colored test outputs

I don't know where this needs to go, but if

fn run_tests(manifest_path: &Path, filter: Option<&str>) -> TestOutcome {
    let mut args: Vec<OsString> = vec![
        "test".into(),
        "--manifest-path".into(),
        manifest_path.into(),
        "-q".into(),
        "--color=always".into()
    ];
...

Then we get colored output. It is not the best ever, but it is something. I don't know where this actually needs to go with this yansi stuff.. So here's the suggestion.

Collected feedback

First of all, this was a great introduction to Rust. It goes through many topics in a logical and easy to follow order, the in-code explanations are great, and the koans tool is nice for managing the tasks. Great work! ๐Ÿ˜„

Here's my feedback from running through it, in no particular order:

Minute feedback

  • In 05_type_as_constraints,rs there is
    /// Has it been saved yet? Is it safe to unwrap whose `Option`s?
    /// That is unnecessary cognitive load and lead to errors down the line,

but maybe it should be

    /// Has it been saved yet? Is it safe to unwrap those `Option`s?
    /// That is unnecessary cognitive load and leads to errors down the line,
  • In 06_results, the example of using Err(ValidationError(... does not use the constructor Err(ValidationError::new("Some error message").

Also, isn't

    impl std::fmt::Display for ValidationError {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }

is supposed to be something like:

    impl std::fmt::Display for ValidationError {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.0)?;
            Ok(())
        }
    }

Maybe write! has changed, since clippy isn't saying anything.

(01) Ticket - Validation

hello,

Im now looking at this part

/// So far we have allowed any string as a valid title and description.
/// That's not what would happen in JIRA: we wouldn't allow tickets with an empty title,
/// for example.
/// Both title and description would also have length limitations: the Divine Comedy probably
/// shouldn't be allowed as a ticket description.
///
/// We want to define a function that takes in a title, a description and a status and
/// performs validation: it panics if validation fails, it returns a `Ticket` if validation
/// succeeds.
///
/// We will learn a better way to handle recoverable errors such as this one further along,
/// but let's rely on panic for the time being.
fn create_ticket(title: String, description: String, status: Status) -> Ticket {
                                                                             todo!()
                                                                                    }
                                                                                    ````

What am I suppose to do ?

and how do I know what a valid title and description is ?

Consider using modules instead of include!

See rust-lang/rust-analyzer#4177.

Just like C headers, include! can be problematic for IDEs because there's no way to offer a good experience in the presence of code like this.

I don't know if it works with full project, but an alternative is to produce something like:

#[path = "koans/00_greetings"]
mod greetings {
    #[path = "00_greetings.rs"]
    mod greetings;
}

instead of

include!("koans/00_greetings/00_greetings.rs");

(02) Ticket Store (01) Store problem

Hello,

I have here to write a get so I did this :

pub fn get(&self, id: &u32) -> &Ticket {
        self.data.get(id)
     }

But that gives me a Option which we did not learn.
So is there another way to make this part work ?

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.