Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Added support for request Id to be either number or string as specifi… #73

Closed
wants to merge 1 commit into from

Conversation

craftytrickster
Copy link
Contributor

This addresses the need to support the id as both a number and a string as identified in - #62.

I am opening the PR to see if this is the approach you would like to take. If you agree, I would like to do more manual testing to make sure this did not break anything prior to merge.

fn visit_str<E>(&mut self, value: &str) -> Result<Id, E> where E: de::Error {
Ok(Id::String(value.to_string()))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you move all this into deserialize

@nrc
Copy link
Member

nrc commented Oct 24, 2016

The approach def. looks good. I had one nit that needs fixing and it needs a rebase, but otherwise r+. Can you check that running cargo test still works?

@nrc
Copy link
Member

nrc commented Oct 24, 2016

Oh, and add a test to the test suite that uses String ids.

@@ -202,14 +204,20 @@ fn init_env(project_dir: &str) {
env::set_current_dir(cwd).expect(FAIL_MSG);
}

#[derive(Clone, Debug, PartialEq)]
enum Id {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to reuse the Id struct from the main code, or should there be a separation like here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need either. I think that each test case should be able to specify an id in ad hoc manner. I.e., they would only test the id if that is what they are testing, if it doesn't matter, then they can use id 0 or 42 or whatever

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants