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

deer implement Deserialize for built-in types (Part 1) #1516

Merged
merged 69 commits into from
Jan 17, 2023
Merged

Conversation

indietyp
Copy link
Member

@indietyp indietyp commented Nov 28, 2022

🌟 What is the purpose of this PR?

This implements Deserialize for a select built-in types.

🔗 Related links

🚫 Blocked by

📹 Demo

@github-actions github-actions bot added the area/libs > deer Affects the `deer` crate (library) label Nov 28, 2022
@indietyp indietyp mentioned this pull request Nov 30, 2022
2 tasks
@indietyp indietyp changed the title deer implement Deserializefor built-in types deer implement Deserialize for built-in types Nov 30, 2022
@vercel
Copy link

vercel bot commented Dec 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
hash 🔄 Building (Inspect) Jan 6, 2023 at 7:11PM (UTC)
hash-design-system 🔄 Building (Inspect) Jan 6, 2023 at 7:11PM (UTC)
hashdotdev 🔄 Building (Inspect) Jan 6, 2023 at 7:11PM (UTC)

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #1516 (28942ce) into main (e155952) will increase coverage by 1.94%.
The diff coverage is 67.10%.

@@            Coverage Diff             @@
##             main    #1516      +/-   ##
==========================================
+ Coverage   55.10%   57.05%   +1.94%     
==========================================
  Files         251      260       +9     
  Lines       18076    18371     +295     
  Branches      421      421              
==========================================
+ Hits         9961    10481     +520     
+ Misses       8110     7885     -225     
  Partials        5        5              
Flag Coverage Δ
backend-integration-tests 3.66% <ø> (ø)
deer 65.06% <67.10%> (+10.78%) ⬆️
unit-tests 1.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/libs/deer/desert/src/lib.rs 100.00% <ø> (ø)
packages/libs/deer/src/impls/core/atomic.rs 0.00% <0.00%> (ø)
packages/libs/deer/src/number.rs 43.52% <12.50%> (+43.52%) ⬆️
packages/libs/deer/src/lib.rs 37.14% <35.38%> (+18.24%) ⬆️
packages/libs/deer/src/impls/core/string.rs 50.00% <50.00%> (ø)
packages/libs/deer/src/impls/core/bool.rs 53.84% <53.84%> (ø)
packages/libs/deer/src/impls/core/floating.rs 53.84% <53.84%> (ø)
packages/libs/deer/src/impls/core/unit.rs 53.84% <53.84%> (ø)
packages/libs/deer/src/schema.rs 90.90% <57.14%> (+9.99%) ⬆️
packages/libs/deer/src/impls/core/array.rs 74.03% <74.03%> (ø)
... and 17 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@indietyp indietyp marked this pull request as ready for review January 11, 2023 15:19
@indietyp indietyp changed the title deer implement Deserialize for built-in types deer implement Deserialize for built-in types (Part 1) Jan 11, 2023
Copy link
Contributor

@thehabbos007 thehabbos007 left a comment

Choose a reason for hiding this comment

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

Looks great, Bilal! I left some comments. The error messages/structure and general composibility is turning out to look very neat!

packages/libs/deer/Cargo.toml Show resolved Hide resolved
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-11-14"
Copy link
Contributor

Choose a reason for hiding this comment

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

Slightly unrelated to PR, but do we want to bump the channel soon?

T: Deserialize<'de> + Debug,
Value: PartialEq<E>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen this sort of syntax before. Is Value the serde_json Value Enum? Why do we need to set a specific bound for it to be PartialEq here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I need to change this, I initially added this for better diagnostics, but similar fails to display a diff between two different types properly. I need to change this so that the error is "casted" to the error enum instead. The bound is here because

assert_eq! requires that the LHS implements PartialEq. Therefore the bound was needed, and not the other way around.

Copy link
Member Author

Choose a reason for hiding this comment

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

reworked in af34989

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great!

packages/libs/deer/desert/src/token.rs Outdated Show resolved Hide resolved
packages/libs/deer/desert/src/token.rs Outdated Show resolved Hide resolved
packages/libs/deer/desert/src/token.rs Show resolved Hide resolved
packages/libs/deer/src/error/type.rs Show resolved Hide resolved
packages/libs/deer/src/impls/core/array.rs Show resolved Hide resolved
packages/libs/deer/src/impls/core/mod.rs Outdated Show resolved Hide resolved
indietyp and others added 3 commits January 16, 2023 19:15
Co-authored-by: Ahmad Sattar <thehabbos007@gmail.com>
…er/stdlib

# Conflicts:
#	packages/libs/deer/desert/src/token.rs
Copy link
Contributor

@thehabbos007 thehabbos007 left a comment

Choose a reason for hiding this comment

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

Happy for this to merge. The remaining open comment is just a follow-up and does not blocking merging :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/libs > deer Affects the `deer` crate (library)
Development

Successfully merging this pull request may close these issues.

None yet

2 participants