Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'r' byte to deserialize_any() #114

Merged
merged 5 commits into from
Jun 8, 2018

Conversation

ebkalderon
Copy link
Contributor

Fixed

  • Update pattern in deserialize_any() to accommodate for raw string literals.

Fixes #113.

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

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

Could you add a large integration test that deserializes all types we have into Value? You can just copy most things from the other tests and add the missing data types.

@ebkalderon
Copy link
Contributor Author

@torkleyy Sure, I can do that.

@ebkalderon
Copy link
Contributor Author

Okay, I've added the integration test. In the process of doing so, however, it seems that the changes needed to accommodate raw string literals were more involved than simply adding another match pattern.

I had an issue in deserialize_any() where identifier() was being triggered accidentally due to the first byte of a raw string literal being "r". To fix this, I updated the method to branch when a b'r' is detected to check whether the next byte is a b'"' or a b'#' before declaring the rest an identifier.

@ebkalderon
Copy link
Contributor Author

@torkleyy Everything should be up-to-date with the latest master now.

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

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

Looking at deserialize_any, I wonder if it even handles enum variants.

if IDENT_FIRST.contains(&next) {
// If the next two bytes signify the start of a raw string literal,
// return an error.
if next == b'r' {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not quite sure why we need this extra check here, sorry.

Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot to delete this comment, it makes sense with the current code, but I'm not sure it's the right way.

Copy link
Contributor Author

@ebkalderon ebkalderon Jun 8, 2018

Choose a reason for hiding this comment

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

@torkleyy The only reason I added this branch is to only perform the second byte check if the next byte is an r. However, I agree that it may not be the best way. This was the best solution I could come up with, however, given the current code structure. If you have any better ideas, please let me know and I'll implement them!

@ebkalderon
Copy link
Contributor Author

ebkalderon commented Jun 8, 2018

@torkleyy It appears that neither deserialize_enum() nor deserialize_identifier() is handled by the pre-existing deserialize_any(). However, I think that this change may need to be made in a separate pull request as it is orthogonal to the scope of this PR, which is to hook up raw string literals with deserialize_any().

I'd be happy to open a separate issue for these problems, if you'd like.

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

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

Okay, I'll merge this but please do not publish yet.
bors r+

bors bot added a commit that referenced this pull request Jun 8, 2018
114: Add 'r' byte to deserialize_any() r=torkleyy a=ebkalderon

### Fixed

* Update pattern in `deserialize_any()` to accommodate for raw string literals.

Fixes #113.

Co-authored-by: Eyal Kalderon <[email protected]>
Co-authored-by: Eyal Kalderon <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 8, 2018

Build succeeded

@bors bors bot merged commit 019af50 into ron-rs:master Jun 8, 2018
@ebkalderon ebkalderon deleted the raw-string-literals branch June 8, 2018 08:22
bors bot added a commit that referenced this pull request Oct 28, 2019
195: Update base64 requirement from 0.10 to 0.11 r=kvark a=dependabot-preview[bot]

Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version.
<details>
<summary>Changelog</summary>

*Sourced from [base64's changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md).*

> - 0.11.0
> - Minimum rust version 1.34.0
> - `no_std` is now supported via the two new features `alloc` and `std`.
> 
> # 0.10.1
> 
> - Minimum rust version 1.27.2
> - Fix bug in streaming encoding ([#90](https://github-redirect.dependabot.com/marshallpierce/rust-base64/pull/90)): if the underlying writer didn't write all the bytes given to it, the remaining bytes would not be retried later. See the docs on `EncoderWriter::write`.
> - Make it configurable whether or not to return an error when decoding detects excess trailing bits.
> 
> # 0.10.0
> 
> - Remove line wrapping. Line wrapping was never a great conceptual fit in this library, and other features (streaming encoding, etc) either couldn't support it or could support only special cases of it with a great increase in complexity. Line wrapping has been pulled out into a [line-wrap](https://crates.io/crates/line-wrap) crate, so it's still available if you need it.
>   - `Base64Display` creation no longer uses a `Result` because it can't fail, which means its helper methods for common
>   configs that `unwrap()` for you are no longer needed
> - Add a streaming encoder `Write` impl to transparently base64 as you write.
> - Remove the remaining `unsafe` code.
> - Remove whitespace stripping to simplify `no_std` support. No out of the box configs use it, and it's trivial to do yourself if needed: `filter(|b| !b" \n\t\r\x0b\x0c".contains(b)`.
> - Detect invalid trailing symbols when decoding and return an error rather than silently ignoring them.
> 
> # 0.9.3
> 
> - Update safemem
> 
> # 0.9.2
> 
> - Derive `Clone` for `DecodeError`.
> 
> # 0.9.1
> 
> - Add support for `crypt(3)`'s base64 variant.
> 
> # 0.9.0
> 
> - `decode_config_slice` function for no-allocation decoding, analogous to `encode_config_slice`
> - Decode performance optimization
> 
> # 0.8.0
> 
> - `encode_config_slice` function for no-allocation encoding
> 
> # 0.7.0
> 
> - `STANDARD_NO_PAD` config
> - `Base64Display` heap-free wrapper for use in format strings, etc
> 
> # 0.6.0
> 
> - Decode performance improvements
> - Use `unsafe` in fewer places
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`edc3859`](marshallpierce/rust-base64@edc3859) v0.11.0
- [`07b1d6b`](marshallpierce/rust-base64@07b1d6b) Merge pull request [#117](https://github-redirect.dependabot.com/marshallpierce/rust-base64/issues/117) from eclipseo/patch-1
- [`e923d5f`](marshallpierce/rust-base64@e923d5f) Bump criterion to 0.3
- [`9ae0292`](marshallpierce/rust-base64@9ae0292) Merge pull request [#116](https://github-redirect.dependabot.com/marshallpierce/rust-base64/issues/116) from Shnatsel/patch-1
- [`85623ca`](marshallpierce/rust-base64@85623ca) Advertise that unsafe code is forbidden
- [`a40d420`](marshallpierce/rust-base64@a40d420) Merge pull request [#111](https://github-redirect.dependabot.com/marshallpierce/rust-base64/issues/111) from CryZe/no-std
- [`b4da176`](marshallpierce/rust-base64@b4da176) Write Documentation and add CI for no_std
- [`3e0fe90`](marshallpierce/rust-base64@3e0fe90) Bump Minimum Version to 1.34.0
- [`6d44a63`](marshallpierce/rust-base64@6d44a63) Implement Support for no_std
- [`d4cd64f`](marshallpierce/rust-base64@d4cd64f) Merge pull request [#114](https://github-redirect.dependabot.com/marshallpierce/rust-base64/issues/114) from marshallpierce/forbid-unsafe
- Additional commits viewable in [compare view](marshallpierce/rust-base64@v0.10.0...v0.11.0)
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants